[PHP] Re: apache htaccess mod rewrite with php querystring urls
Raisinlove a écrit : Hi, I realize this isnt specificaly related to php, but most php hi developers are familiar with this. My website uses an index.php file to load all content with a template, using urls like so: http://www.foo.com/index.php?page=splash.html In the same directory, there is a file called splash.html, but what I would like to do is that if the source file is called, the php file would load instead. So typing in: http://www.foo.com/splash.html would bring up: http://www.foo.com/index.php?page=splash.html instead. The solution I found was to use an .htaccess file, but it only brings up a 403 forbidden access error everytime. ModRewrite is enabled, so what could be the problem? Here is the code I used: RewriteEngine on RewriteBase / RewriteRule ^[A-Za-z0-9]\.html$ /index.php?page=$1 [A-Za-z0-9] will only match one character. Try this : RewriteEngine on RewriteRule [A-Za-z0-9]+\.html$ /index.php?page=$1 thanks for your help :) -steph -- Fabrice Lezoray http://classes.scriptsphp.fr - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: apache htaccess mod rewrite with php querystring urls
[A-Za-z0-9] will only match one character. Try this : RewriteEngine on RewriteRule [A-Za-z0-9]+\.html$ /index.php?page=$1 Ah, good point there. Thanks. However, I'm still experiencing problems displaying any page contained within the folder which holds this htaccess file. I get a 403 Forbidden Access error everytime. Your example above is the only code contained in my file. What could be the cause of this, and how can I fix it? thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: apache htaccess mod rewrite with php querystring urls
On Thu, 12 Aug 2004 14:19:07 +0200, in php.general you wrote: [A-Za-z0-9] will only match one character. Try this : RewriteEngine on RewriteRule [A-Za-z0-9]+\.html$ /index.php?page=$1 $1 would be a backreference, but there are no capturing parenthesis. RewriteRule ([A-Za-z0-9]+\.html)$ /index.php?page=$1 However, I'm still experiencing problems displaying any page contained within the folder which holds this htaccess file. I get a 403 Forbidden Access error everytime. It's pretty simple, though: If you get an error, check your error log for Apache (default written to logs/error.log). It would give you the reason for you Apache has given a 403-error to the client. Still, this is not much of a PHP issue. Since Rewrite-magic tend to be pretty complicated (and there are a couple of misunderstandings regarding this feature), I do think some Apache mailing lists would be of more help for you. -- - Peter Brodersen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php