Scenario:
Example:
http://somesite.com/mydir/a
http://somesite.com/mydir/b
http://somesite.com/mydir/c
etc...
To be rewritten as:
http://somesite.com/mydir/vie
http://somesite.com/mydir/vie
http://somesite.com/mydir/vie
etc...
Except:
http://somesite.com/mydir rewrite--> /mydir/home.html
http://somesite.com/mydir/hom
http://somesite.com/mydir/abo
Solution:
These rules should go in an .htaccess file in the "mydir" directory:
DirectoryIndex home.html
Options +FollowSymLinks
RewriteEngine on
RewriteBase /mydir/
RewriteCond %{REQUEST_URI} ^/mydir/(home|about)$
RewriteRule ^.*$ %1.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ view.php?p=$1 [L]
Related links
- sandip's blog
- Login or register to post comments
Comments
DirectoryIndex home.html
Options +FollowSymLinks
RewriteEngine on
RewriteBase /mydir/
RewriteCond %{REQUEST_URI} ^/mydir/(home|about)$
RewriteRule ^.*$ %1.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ view.php?p=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ view.php?p=$1&q=$2 [L]
Note:
"[^/]+" matches one or more characters not equal to a slash.
"?" matches 0 or more.