.htaccess

Redirecting a dynamic URL to another dynamic URL using htaccess

这一生的挚爱 提交于 2021-02-10 18:47:52
问题 I'm trying to redirect a dynamic URL which is as follows: http://example.com/manage/billing/invoice/all/viewinvoice.php?id=1541 and I need it to redirect to: http://example.com/manage/billing/invoice/1541/ I want to do this using .htaccess I got as far as this but I cannot seem to get it to work: RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /manage/billing/invoice/all/viewinvoice\.php\?id=([^\ ]*) RewriteRule ^ /manage/billing/invoice/all/%1 [L,R=301] Anyone got any suggestions? 回答1: Add this to

CodeIgniter 4… documentRoot is not in public… htaccess is not working

早过忘川 提交于 2021-02-10 18:45:29
问题 I am starting to dabble in CodeIgniter 4. Completed a simple app. On local, I have the documentroot setup to be /public/ where as on the product hosting environment, I am unable to set the documentroot to be in /public/. Instead it is in /root. So the structure is like so: /root ../admin ../app ../system ../public ../.htaccess ../index.php I've moved the htaccess from the public folder to the root level. # Disable directory browsing Options All -Indexes # -------------------------------------

CodeIgniter 4… documentRoot is not in public… htaccess is not working

杀马特。学长 韩版系。学妹 提交于 2021-02-10 18:40:47
问题 I am starting to dabble in CodeIgniter 4. Completed a simple app. On local, I have the documentroot setup to be /public/ where as on the product hosting environment, I am unable to set the documentroot to be in /public/. Instead it is in /root. So the structure is like so: /root ../admin ../app ../system ../public ../.htaccess ../index.php I've moved the htaccess from the public folder to the root level. # Disable directory browsing Options All -Indexes # -------------------------------------

Preety url with htaccess

只谈情不闲聊 提交于 2021-02-10 18:19:32
问题 I have url localhost/product/q.php?id=1&product=my-product how to make the url into localhost/product/1/my-product using .htaccess 回答1: You use a RewriteRule which consists of a regex to apply to the pretty URL accessed by the user and a replacement which will then be used by the server/scripts. RewriteRule ^product/(\d+)/(.*)$ /product/q.php?id=$1&product=$2 [L] RewriteRule : Type of action ^product/(\d+)/(.*)$ : Regex to run against URL /product/q.php?id=$1&product=$2 : Replacement URL [L]

.htaccess rewriting PATH_INFO vars to empty before passing to template; not removing index.php from url

旧巷老猫 提交于 2021-02-10 17:50:44
问题 Morning everyone, I'm hoping this will be an easy one! (I haven't even had coffee yet why am I up so early?!) Anyway.. got a two-parter for you: First (basic) issue that I'm trying to remove index.php from my links (which seems to be next to impossible thanks hostgator :) ). After a bunch of searching I've gotten to the point where /page redirects to /index.php/page. Now this is better than nothing, but of course still not ideal. And I had to use [R] to do it. My .htaccess is: RewriteCond %

How can I redirect subdomains in .htaccess to www. with generic parameters?

夙愿已清 提交于 2021-02-10 16:40:59
问题 I am looking for a working solution for the following problem: I have many domains with same website. When somebody goes to www.domainname.tld there should be redirection to http://www.domainname.tld When somebody goes to subdomain.domainname.tld there should be redirection to http://www.domainname.tld When somebody goes to domainname.tld there should be redirection to http://www.domainname.tld. =========================== I tried the following: RewriteCond %{HTTP_HOST} !^www\. RewriteRule (.

Ubuntu 16.04 can't enable .htaccess

我怕爱的太早我们不能终老 提交于 2021-02-10 16:12:51
问题 I'm developing a website local and just switched from Windows to Ubuntu 16.04 - Sadly my .htaccess doesn't seems to work since rewrite rules don't apply and sources can't be found. I activated: sudo a2enmod rewrite rewrite_rule (shared) is listed via: sudo apache2ctl -M My website files (including my .htaccess) are located under /var/www/html My .htaccess Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / # Hide Index IndexIgnore * # Forbid accessing certain sites

htaccess - how to apply RegEx patterns on the output of another - encapsulation

无人久伴 提交于 2021-02-10 15:44:24
问题 I'm performing several regular expressions on a string inside a variable in order to clean it up for further use in the htaccess rules, but it seems rather cumbersome to do such simple thing in several lines: RewriteCond %{THE_REQUEST} (?<=\s)(.*?)(?=\s) RewriteRule ^(.*)$ - [E=HREFPATH:%1] RewriteCond %{ENV:HREFPATH} (^.*)?\? RewriteRule ^(.*)$ - [E=HREFPATH:%1] RewriteCond %{ENV:HREFPATH} /(.*) RewriteRule ^(.*)$ - [E=HREFPATH:%1] RewriteCond %{ENV:HREFPATH} (.*)/$ RewriteRule ^(.*)$ - [E

When to use [L] flag in mod_rewrite

倾然丶 夕夏残阳落幕 提交于 2021-02-10 13:24:10
问题 Can someone give me an example when to use [L] flag? I'm learning about mod_rewrite moudle in .htaccess file and can't find out when to this flag. 回答1: The L flag simply means to stop applying any rules that follow. Given the same URL, http://example.com/foo/bar?q=blah , and given the rules: RewriteRule ^foo - RewriteCond %{REQUEST_URI} !^/bar.php RewriteRule ^(.*)$ /bar.php?z=$1 The first rule gets applied and the URI gets passed through unchanged (via the - target). The rewrite engine then

Directing Non-Slash URL to Slash

☆樱花仙子☆ 提交于 2021-02-10 11:12:14
问题 When I enter the website.com/seo link, I want to make a 301 redirect to the website.com/seo/ link. However, I don't want it to be broken in the codes I wrote in the current htaccess. my htacces codes: RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*?)/?$ $1.php [NC,L] 回答1: Use only one of these, do not use together! Try: RewriteEngine