|
Aug
31
4
|
ROTD: Mod_rewrite Rule To Remove Trailing "index.php" |
|||||
This handy set of rules for mod_rewrite automatically redirects any URL ending in "/index.php" to the same URL ending in "/." It works for the root directory as well as subdirectories. RewriteCond %{THE_REQUEST} ^GET\ /.*/index\.(php|html)\ HTTP For example, "http://www.example.com/subdirectory/index.php" would be redirected to "http://www.example.com/subdirectory/." This eliminates one of the peskier canonicalization issues with relative ease. It's a bit tricky because of the way mod_rewrite updates its variables during execution — hence the odd use of the variable {THE_REQUEST}. If anyone knows an easier way or finds a problem with it, leave a comment. Related posts: What Mod_rewrite Won't Do For You I've seen many misconceptions about mod_rewrite. I believe this is... URL Canonicalization (/ vs. index.php) Unfortunately, the concept of "index" pages (index.php, Default.asp, etc.), a... blog.yourcompany.com vs. yourcompany.com/blog It has become popular for companies to create corporate blogs... SEO-Related Apache Exploit Most deployed versions of Apache are potentially exploitable, as mod_rewrite... ROTD: Removing CSS Bloat This function, comprised of a simple regular expression, will remove...
| ||||||
"4 Wise Comments Banged Out Somewhere On The Internet ..."
Thankks. I have been looking for something like this for some time. I'll implement it and in case I run into any trouble, I'll let you know. Cheers
Nice, I've been using something similar: RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.html\ HTTP/ (hopefully that formats ok.) I think the one you have may be a bit better because it works for subdirectories and php files too.
Hello, I have a webpage : http://bonrouge.com/br.php?page=home I want it to be viewed as http://bonrouge.com/home php using the mod rewrite rule. I have tried both of the above codes, but to no avail.
This doesnt work for me. Everything gets redirected to / without the subdirectory. I'm using wamp 1.7.0.
|


















