Reputation: 321
I want to redirect test.com/folder/create
to test.com/folder/create(.php)
but anything after /folder/
is perceived as a $_GET[]
variable with the lines below
RewriteCond %{REQUEST_URI} !^/folder/index\.php$ [NC]
RewriteRule ^folder/([^/]*)$ /folder/index.php?type=$1
Ive tried
RewriteCond %{REQUEST_URI} !^/folder/create\.php$ [NC]
RewriteRule ^folder/create$ /folder/create.php
But no luck (Error 500), can anyone point me in the right direction on how i could possibly do this?
EDIT: Still trying to search the web for an answer, no luck
EDIT: Small edit, Current Code
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} !^item\.php$
RewriteRule ^([^/]+)/?$ index.php?type=$1 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?type=$1&page=$2 [L,QSA]
RewriteRule ^item/([^/]+)/?$ item.php?id=$1 [L,QSA]
RewriteRule ^item/([^/]+)/([^/]+)/?$ item.php?id=$1&page=$2 [L,QSA]
The rewrite base is /folder/ /folder/item works and redirect to item.php /folder/item/2 gives a 500 Error, any suggestions?
Upvotes: 1
Views: 125
Reputation: 785196
You can use these rules in your folder/.htaccess
(not in site root .htaccess):
DirectoryIndex index.php
RewriteEngine On
RewriteBase /folder/
# append .php extension to every request that has a corresponding .php file
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
# rewrite all non-existing files and folders to index,php?type=...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .+ index.php?type=$0 [L,QSA]
Upvotes: 1
Reputation: 18671
Try only with:
Options -MultiViews
RewriteRule ^folder/create$ folder/create.php
Upvotes: 1