Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

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

Posts: 164
Name: James
Location: marbella & surrey
Trades: 0
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
__________________

Please login or register to view this content. Registration is FREE
- private villas direct from the owners - travel links always needed.
purk is offline
Reply With Quote
View Public Profile Visit purk's homepage!
 
 
Register now for full access!
Old 09-10-2007, 07:43 AM Re: Where'd I go wrong with mod_rewrite?
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
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 07:50 AM..
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 09-10-2007, 07:54 AM Re: Where'd I go wrong with mod_rewrite?
purk's Avatar
Extreme Talker

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

This is very strange. Any other ideas?
__________________

Please login or register to view this content. Registration is FREE
- 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, 08:01 AM Re: Where'd I go wrong with mod_rewrite?
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
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, 08:14 AM Re: Where'd I go wrong with mod_rewrite?
purk's Avatar
Extreme Talker

Posts: 164
Name: James
Location: marbella & surrey
Trades: 0
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!
__________________

Please login or register to view this content. Registration is FREE
- 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, 08:25 AM Re: Where'd I go wrong with mod_rewrite?
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
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, 08:32 AM Re: Where'd I go wrong with mod_rewrite?
purk's Avatar
Extreme Talker

Posts: 164
Name: James
Location: marbella & surrey
Trades: 0
yep, it is loaded under the apache loaded modules section.
__________________

Please login or register to view this content. Registration is FREE
- 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, 08:35 AM Re: Where'd I go wrong with mod_rewrite?
purk's Avatar
Extreme Talker

Posts: 164
Name: James
Location: marbella & surrey
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
- private villas direct from the owners - travel links always needed.

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

Posts: 164
Name: James
Location: marbella & surrey
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
- 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 Search this Thread
Search this Thread:

Advanced Search

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

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





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



Page generated in 1.22724 seconds with 12 queries