Reputation: 730
im trying to shorten my URL's using mod rewrite.
I would like to shorten urls from /class/hello.php
and instead just use /hello.php
In my .htaccess im currently trying to use
RewriteEngine on
Options +FollowSymlinks
RewriteBase /website
RewriteRule ^/.+[.]php$ class/$1.php [L]
which does not seem to be working
Upvotes: 1
Views: 143
Reputation: 785156
You can use this code in /website/.htaccess
:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /website/
RewriteCond $1 !^index\.php$ [NC]
RewriteRule ^((?!class/)[^/]+?\.php)$ class/$1 [NC,L]
Upvotes: 1
Reputation: 43852
You need to actually capture the part of the regular expression with parentheses to be interpolated in place of the the $1
variable.
RewriteRule ^/(.+)[.]php$ class/$1.php [L]
Upvotes: 0