htaccess redirect index.php to root (including subdomains)
Do this: RewriteCond %{THE_REQUEST} ^.*/index\.php RewriteRule ^(.*)index.php$ /$1 [R=301,L]
Do this: RewriteCond %{THE_REQUEST} ^.*/index\.php RewriteRule ^(.*)index.php$ /$1 [R=301,L]
Click on Wamp icon and open Apache/httpd.conf and search “#LoadModule rewrite_module modules/mod_rewrite.so”. Remove # as below and save it LoadModule rewrite_module modules/mod_rewrite.so and restart all service.
You can use the RewriteRule flag S|skip to tie multiples RewriteRules to a single RewriteCond (or to a set of RewriteConds). Here is an example that applies one Cond to three Rules: RewriteCond %{HTTP_HOST} !^www.mydomain.com$ # skip rules if NOT within domain – only way to tie multiple rules to one cond RewriteRule .? – … Read more
One approach is to rewrite everything to a handling script RewriteEngine on RewriteBase / # only rewrite if the requested file doesn’t exist RewriteCond %{REQUEST_FILENAME} !-s # pass the rest of the request into index.php to handle RewriteRule ^(.*)$ /index.php/$1 [L] so if you have a request to http://yourserver/foo/bar/ what you actually get is a … Read more
You’ll need to use Javascript to read this. There are a few different options – upon page load, you could use an XmlHTTPRequest (AJAX request) to tell the server what the additional URL parameters were. Alternatley you could check to see if there are additional parameters (also via Javascript), and if you find any, post … Read more
The regex on the RewriteRule is only run against the path part of the URL, not the query parameters. Fortunately there is the [QSA] flag to preserve existing query parameters.
To automatically add a www to your domain name when there isn’t a subdomain, add this to the htaccess file in your document root: RewriteEngine On RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
The accepted answer to this question is outdated. You can now use the FallbackResource directive in your conf file with Apache 2.2.16+. FallbackResource /app/index.html If you want the FallbackResource directive to ignore the “/api” routes: <Directory /api> FallbackResource disabled </Directory>
(I tried $1%20$2 at the end, which also went badly). This looks like a bug. Encoding the space as %20 in the query string should be valid. You can also encode the space as + in the query string (as in your workaround). In your original rule, Apache should be encoding the space (as %20) … Read more
You can use this rule: RewriteRule ^menu\.php$ /new-page-name? [L,R=301] Take note of trailing ? in the end which is used for stripping off any existing query string in the original URI.