Forum Moderators: phranque
RewriteEngine on
AddType application/x-httpd-php .php .html
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^([^.]+)\.html$ mypage.php?name=$1 [QSA,L]
--------
Now I need to add 2 more thing:
1. the file call can be htm and not only html
2. the file call can haven't extension
So:
example.html
or
example.htm
or
example << if NOT a dir
must be rewrite to mypage.php?name=...
How to make this?
Thanks
# if requested URI does not exist as a real file
RewriteCond %{REQUEST_FILENAME} !-f
# and if requested URI does not exist as a real directory
RewriteCond %{REQUEST_FILENAME} !-d
# rewrite .htm, .html, or extensionless URIs to constructor.php
RewriteRule ^([^.]+)(\.html?)?$ constructor.php?name=$1 [QSA,L]
I try to explain better
This is code that you have suggest, that is perfect :)
# if requested URI does not exist as a real file
RewriteCond %{REQUEST_FILENAME}!-f
# and if requested URI does not exist as a real directory
RewriteCond %{REQUEST_FILENAME}!-d
# rewrite .htm, .html, or extensionless URIs to constructor.php
RewriteRule ^([^.]+)(\.html?)?$ constructor.php?name=$1 [QSA,L]
at this time:
user digit example
if example not exist is rewrite with constructor
I need to add this check
user digit example
if example exist ok
if example not exist:
--> check if exist example.html
--> if yes rewrite to example.html
else (if example and example.html not exist) rewrite to constructor.php
I need to add only 1 chek before rewrite tha redirect (if exist .html) to him
Thks
# if requested URI does not exist as a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# but does exist as a file with ".html" appended
RewriteCond %{REQUEST_FILENAME}.html -f
# then rewrite extensionless URI to .html file
RewriteRule ^([^.]+)$ $1.html [L]
#
# if requested URI does not exist as a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# rewrite .htm, .html, or extensionless URIs to constructor.php
RewriteRule ^([^.]+)(\.html?)?$ constructor.php?name=$1 [QSA,L]
[edited by: jdMorgan at 4:32 pm (utc) on Mar. 14, 2007]