Forum Moderators: phranque

Message Too Old, No Replies

Simple mod_rewrite problem

page cannot be displayed error

         

zeeshan12

5:39 pm on Mar 22, 2005 (gmt 0)

10+ Year Member



Hi,

i'm using a simple mod_rewrite script to get started with.

RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule test/(.*)$ test.php?a=$1

now with this i assume if i put "www.site.com/test/something/"
in my address bar i must get a variable "a" on page "test.php" with a value of "something". but when I put this url in the address bar i get "page cannot be displayed error".

can anyone please have a look

thanks

jdMorgan

10:46 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



zeeshan12,

What does your error log contain after you test this code?

The code itself looks OK, but you may need to change your AllowOverride settings. Also, if there is an existing subdirectory named "test", then you may need to add the directive "RewriteOptions inherit" to the .htaccess file in that subdirectory.

Jim

zeeshan12

9:31 am on Mar 23, 2005 (gmt 0)

10+ Year Member



Hi Jim,

First of all thanks for takin the time to reply. I have checked my error log n i'ev found this in it.

File does not exist: C:/Apache2/htdocs/site_dir/test

donno wot it means :(

zeeshan12

4:29 pm on Mar 23, 2005 (gmt 0)

10+ Year Member



Hi,

I have given up the whole idea of writing mod-rewrite conditions for mysite. I am gonna do it through php but i still need a url rewrite script that sends all the requests to one php script

so if i click on this link

<a href="category1/category2/">Category2</a>

the mod_rewrite must write it to this

mysite.com/show.php?q=category1/category2/

i am using this simple script but i keep getting "page not found error"

<Directory />
AllowOverride All
</Directory>

RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule /(.*)$ show.php?q=$1

Thanks
zeeshan

zeeshan12

5:53 pm on Mar 23, 2005 (gmt 0)

10+ Year Member



got it working.....this is the right script

RewriteEngine on
Options +FollowSymLinks
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ show.php?q=$1 [L]