Reply
Where'd I go wrong with mod_rewrite?
Old 09-10-2007, 08:15 AM Where'd I go wrong with mod_rewrite?
purk's Avatar
Extreme Talker

Posts: 164
Name: James
Location: marbella & surrey
Can anyone tell me what's wrong with my mod_rewrite rule?
fyi: my host does support .htaccess and the mod_rewrite module is installed according to phpinfo().

RewriteEngine on
RewriteRule ^/([a-zA-Z0-9-]+)/?$ page.php?page=$1 [L]

what i'm trying to achieve is to allow a user to go to
www.mydomain.com/[username] which uses this page www.mydomain.com/page.php?page=[username]

is it because i'm using the root level and should be using a subdirectory?

if it isn't obvious i'm close to clueless about anything to do with .htaccess but from the handful of tutorials i have found there should be nothing wrong with my rule.

any input would be great.
cheers folks.


;purk
__________________
thatVilla.com - private villas direct from the owners - travel links always needed.
purk is offline
Reply With Quote
View Public Profile Visit purk's homepage!
 
When You Register, These Ads Go Away!
Old 09-10-2007, 08:43 AM Re: Where'd I go wrong with mod_rewrite?
maxxximus's Avatar
Extreme Talker

Posts: 206
Name: Rob
Location: UK
The following should work if you stick it in Root

RewriteEngine On
RewriteRule ^(.*) page.php?page=$1

or better still use a more descriptive rewrite such as

RewriteEngine On
RewriteRule ^descriptivewords/descriptivewords/(.*) page.php?page=$1

where you substitute descriptivewords for your keywords.

Last edited by maxxximus : 09-10-2007 at 08:50 AM.
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 09-10-2007, 08:54 AM Re: Where'd I go wrong with mod_rewrite?
purk's Avatar
Extreme Talker

Posts: 164
Name: James
Location: marbella & surrey
I tried your suggestion but I still just get a 404!

This is very strange. Any other ideas?
__________________
thatVilla.com - private villas direct from the owners - travel links always needed.
purk is offline
Reply With Quote
View Public Profile Visit purk's homepage!
 
Old 09-10-2007, 09:01 AM Re: Where'd I go wrong with mod_rewrite?
maxxximus's Avatar
Extreme Talker

Posts: 206
Name: Rob
Location: UK
Try adding a 'Options FollowSymLinks' to the top.

Some servers already have this set so you don't need to declare it.

Try it - should work if its installed on your server.


maxxximus is offline
Reply With Quote
View Public Profile
 
Old 09-10-2007, 09:14 AM Re: Where'd I go wrong with mod_rewrite?
purk's Avatar
Extreme Talker

Posts: 164
Name: James
Location: marbella & surrey
nope, still get 404. i'm chatting with my host support, they clearly have no idea other than mod_rewrite is enabled.

this is what i have

Options FollowSymLinks
RewriteEngine On
RewriteRule ^(.*) page.php?page=$1

Could it be that my attribute name a page name are the same? that would be a strange quirk.

Thanks for your input thus far!
__________________
thatVilla.com - private villas direct from the owners - travel links always needed.
purk is offline
Reply With Quote
View Public Profile Visit purk's homepage!
 
Old 09-10-2007, 09:25 AM Re: Where'd I go wrong with mod_rewrite?
maxxximus's Avatar
Extreme Talker

Posts: 206
Name: Rob
Location: UK
You could check your server yourself using <?php phpinfo() ?> and look if mod_rewrite is enabled.
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 09-10-2007, 09:32 AM Re: Where'd I go wrong with mod_rewrite?
purk's Avatar
Extreme Talker

Posts: 164
Name: James
Location: marbella & surrey
yep, it is loaded under the apache loaded modules section.
__________________
thatVilla.com - private villas direct from the owners - travel links always needed.
purk is offline
Reply With Quote
View Public Profile Visit purk's homepage!
 
Old 09-10-2007, 09:35 AM Re: Where'd I go wrong with mod_rewrite?
purk's Avatar
Extreme Talker

Posts: 164
Name: James
Location: marbella & surrey
my host company says 'there is a problem with your syntax' but they also say they don't know what it is!

I found a very simple example which looks like this

RewriteEngine on
RewriteRule ^test.php$ page.php

so when i visit mydomain.com/test.php i should see the content of mydomain.com/page.php but instead i get that darn 404

fyi: test.php does not exist but page.php does.
__________________
thatVilla.com - private villas direct from the owners - travel links always needed.

Last edited by purk : 09-10-2007 at 09:36 AM. Reason: fyi
purk is offline
Reply With Quote
View Public Profile Visit purk's homepage!
 
Old 09-10-2007, 11:56 AM Re: Where'd I go wrong with mod_rewrite?
purk's Avatar
Extreme Talker

Posts: 164
Name: James
Location: marbella & surrey
THIS ISSUE IS NOW SOLVED!

Thanks to maxxximus for the help.

For anyone who's new to mod_rewrite (like me) the issue was that I had defined an option (followsymlinks) before initiating the rewriteengine.

Seems so obvious now after 1.5 days head scratching and reference document reading.
__________________
thatVilla.com - private villas direct from the owners - travel links always needed.
purk is offline
Reply With Quote
View Public Profile Visit purk's homepage!
 
Reply     « Reply to Where'd I go wrong with mod_rewrite?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14557 seconds with 12 queries