TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-18-2008, 04:08 PM   #1 (permalink)
The Contributor
 
oMIKEo's Avatar
 
Join Date: Jan 2008
Location: Leeds
Posts: 52
Thanks: 7
oMIKEo is on a distinguished road
Confused RewriteRule not working...

Hi,

Here is what i have so far.

Friendly URL:
http://site.com/YML/profile/myquickname

Original URL:
http://site.com/YML/profile.php?id=myquickname

.htaccess:
Code:
RewriteEngine On
RewriteBase /
RewriteRule ^YML/profile/(.*)$ /YML/profile.php?id=$1 [L]
Can anyone see where i might be going wrong?

Thanks
Send a message via MSN to oMIKEo
oMIKEo is offline  
Reply With Quote
Old 04-18-2008, 04:30 PM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

There shouldn't be a forward slash at the beginning of the path (/YML/profile.php...) unless you're providing an absolute path (like /home/username/public_html...).
Salathe is offline  
Reply With Quote
Old 04-18-2008, 04:36 PM   #3 (permalink)
The Contributor
 
oMIKEo's Avatar
 
Join Date: Jan 2008
Location: Leeds
Posts: 52
Thanks: 7
oMIKEo is on a distinguished road
Default

thanks for your help, i changed it to the following but its still not doing anything. when i go to the friendly url i just see a 404 error page.

Code:
RewriteEngine On
RewriteBase /
RewriteRule ^YML/profile/(.*)$ YML/profile.php?id=$1 [L]
Send a message via MSN to oMIKEo
oMIKEo is offline  
Reply With Quote
Old 04-19-2008, 01:06 PM   #4 (permalink)
The Contributor
 
flyingbuddha's Avatar
 
Join Date: Jan 2008
Location: Birmingham, UK
Posts: 60
Thanks: 10
flyingbuddha is on a distinguished road
Default

Are you typing in the right case?
Might be best to add the NC flag ([L,NC])

Is the original url working correctly without mod_rewrite? Hard to diagnose without a working url.
__________________
Pro. Geek
http://www.mikeholloway.co.uk
flyingbuddha is offline  
Reply With Quote
Old 04-19-2008, 05:07 PM   #5 (permalink)
The Contributor
 
oMIKEo's Avatar
 
Join Date: Jan 2008
Location: Leeds
Posts: 52
Thanks: 7
oMIKEo is on a distinguished road
Default

"Are you typing in the right case?" - Do you mean the YML in capitals? if so yes, thats exactly as it is structured.

The original link ( http://site.com/YML/profile.php?id=myquickname ) is working fine on the site but the mod rewrite still isnt doing anything. Here is what it looks like now:

Code:
RewriteEngine On
RewriteBase /
RewriteRule ^YML/profile/(.*)$ YML/profile.php?id=$1 [L,NC]
Send a message via MSN to oMIKEo
oMIKEo is offline  
Reply With Quote
Old 04-19-2008, 05:57 PM   #6 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

Are you sure your web server has "AllowOverride ALL" configured??
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 04-19-2008, 06:01 PM   #7 (permalink)
The Contributor
 
oMIKEo's Avatar
 
Join Date: Jan 2008
Location: Leeds
Posts: 52
Thanks: 7
oMIKEo is on a distinguished road
Default

Would i have to contact my hosting company to find that out?
Send a message via MSN to oMIKEo
oMIKEo is offline  
Reply With Quote
Old 04-19-2008, 06:31 PM   #8 (permalink)
The Contributor
 
flyingbuddha's Avatar
 
Join Date: Jan 2008
Location: Birmingham, UK
Posts: 60
Thanks: 10
flyingbuddha is on a distinguished road
Default

Try putting the following in your .htaccess
Code:
Options +followSymlinks
__________________
Pro. Geek
http://www.mikeholloway.co.uk
flyingbuddha is offline  
Reply With Quote
Old 04-19-2008, 06:52 PM   #9 (permalink)
The Contributor
 
oMIKEo's Avatar
 
Join Date: Jan 2008
Location: Leeds
Posts: 52
Thanks: 7
oMIKEo is on a distinguished road
Default

i just found this in my hosting CP:

Code:
<DIRECTORY /hsphere/local/home/mysite/site.com>
OPTIONS  Indexes Includes ExecCGI FollowSymLinks
AllowOverride All
</DIRECTORY>
IndexOptions FancyIndexing
</VirtualHost>
Does that mean it should be working?
Send a message via MSN to oMIKEo
oMIKEo is offline  
Reply With Quote
Old 04-19-2008, 06:48 PM   #10 (permalink)
The Contributor
 
oMIKEo's Avatar
 
Join Date: Jan 2008
Location: Leeds
Posts: 52
Thanks: 7
oMIKEo is on a distinguished road
Default

i tried adding that line before and then after the rewrite, they didnt make any change...
Send a message via MSN to oMIKEo
oMIKEo is offline  
Reply With Quote
Old 04-19-2008, 07:12 PM   #11 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

yes, it's fine then
It must be some syntax problem, I don't really understand the rewrite syntax, so can't help, sorry
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 04-19-2008, 08:05 PM   #12 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Are you sure the rewrite module is loaded in the apache config too? You can check the httpd.conf (search for rewrite), or run phpinfo() and search for mod_rewrite in apache2handler to find out.

I can get this to work on mine,

Code:
RewriteEngine On
RewriteRule ^YML/profile/([0-9]+)/?$ YML/profile.php?id=$1 [L]
(will turn http://yourhost/YML/profile/12/ into http://yourhost/YML/profile.php?id=12 for example. Substitute [A-Za-z0-9]+ for [0-9]+ if you wish to use alphanumeric profile designations too.)
-m
delayedinsanity is offline  
Reply With Quote
Old 04-20-2008, 08:37 AM   #13 (permalink)
The Contributor
 
oMIKEo's Avatar
 
Join Date: Jan 2008
Location: Leeds
Posts: 52
Thanks: 7
oMIKEo is on a distinguished road
Default

mod_rewrite appears under Apache but i still cant get it to work! :S

thanks for everyones help so far, im going to contact the hosting company to see if its something on their side.
Send a message via MSN to oMIKEo
oMIKEo is offline  
Reply With Quote
Old 04-20-2008, 09:51 AM   #14 (permalink)
The Contributor
 
mortisimus's Avatar
 
Join Date: Sep 2007
Location: London, UK
Posts: 47
Thanks: 4
mortisimus is on a distinguished road
Default

Try
Code:
RewriteEngine On
RewriteRule ^YML/profile/(.*)$ http://www.site.com/YML/profile.php?id=$1 [L]
?
mortisimus is offline  
Reply With Quote
Old 04-22-2008, 08:15 PM   #15 (permalink)
The Contributor
 
flyingbuddha's Avatar
 
Join Date: Jan 2008
Location: Birmingham, UK
Posts: 60
Thanks: 10
flyingbuddha is on a distinguished road
Default

try php.net/dl
__________________
Pro. Geek
http://www.mikeholloway.co.uk
flyingbuddha is offline  
Reply With Quote
Old 04-28-2008, 09:03 PM   #16 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Sunnuvabitch. I've been working for so long on my test server, that I didn't realize something very important about my stupid host. A lot of functionality for my web site depends on mod_rewrite. I was going to upload what I have done so far, in order to post it here and have everybody try and break it, to see if anybody could find any bugs, and guess what?? My damned production server doesn't have mod_rewrite!

So I call them to ask them if they can turn it on, and I get some dumb ass working tech support who doesn't know a thing about tech support telling me that they can't turn it on because it could cause problems with other people on the server. After explaining to him three times that it can't possibly hurt anybody, as turning it on doesn't disable any functionality, it only adds functionality, and there's no inherent security risks involve, AND that it's part of apache already, the whole thing would take about four seconds of effort, he promised to "prioritize" my request to the engineering department. That was also after I asked him to talk to somebody who could actually help me, four or five times.

NetworkSolutions is crap. For a company that's been around a long time on the web, you'd think they would have something to offer, but noooo, if anything they've turned into an unethical pile of dog turd. (I mention unethical due to their practice of front running domains, and I'm sure other shizzle too).

Anywho, just had to bitch, I'm going to go and start shopping for a decent host now. Any suggestions? I don't need a dedicated server yet, I just want a simple, affordable host with PHP 5, MySQL 5, and mod_rewrite.
-m
delayedinsanity is offline  
Reply With Quote
Old 04-28-2008, 09:21 PM   #17 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

toastedpenguin.com - Home - I haven't used them (yet) but I can tell their customer support is good from talking with them (over e-mail).
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 01-24-2010, 08:55 PM   #18 (permalink)
The Visitor
 
Join Date: Jan 2010
Posts: 1
Thanks: 0
aguspc1 is on a distinguished road
Default

perhaps you can try this... I hope this can help you.

Agus Pang (http://aguspc1.blogspot.com/)
Jakarta, Indonesia.

open file xampp/apache/conf/httpd.conf

find AllowOverride None
change into AllowOverride All

find
#LoadModule rewrite_module modules/mod_rewrite.so

change into
LoadModule rewrite_module modules/mod_rewrite.so

or

http://blog.taragana.com/index.php/a...-working-in-ht...

I faced a hair-tearing problem. mod_rewrite was loaded and yet it was not working in .htaccess files (and httpd.conf initially). Here is the solution along with how you can debug mod_rewrite problems.

Debugging procedure:
Add these two line to your httpd.conf immediately after RewriteEngine On.
RewriteLog "/var/log/httpd/rewrite_log"
RewriteLogLevel 9
After that I added the required RewriteRule etc.

The reason for testing directly in httpd.conf is to ensure that mod_rewrite is working in the first place. After some debugging I realized my expression was wrong. So now I found mod_rewrite was working in httpd.conf. However it still wasn't working in .htaccess files.

Solution:
I found AllowOverride was set to None in httpd.conf. I changed it to All (after all I am the only user of the machine). And it finally started working everywhere (after a restart).

What I learnt:
Unmanaged dedicated web hosting is really really painful, unless you are (or have) a good linux system administrator. Too many things to setup and too many points of failure. And I haven't even started working on serious hardening stuff.
aguspc1 is offline  
Reply With Quote
Old 01-25-2010, 12:20 AM   #19 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Holy thread revival batman.

Oh and if anybody is wondering, Linode.com, best VPS host hands down.
delayedinsanity is offline  
Reply With Quote
Old 12-06-2011, 09:21 PM   #20 (permalink)
The Visitor
 
Join Date: Dec 2011
Posts: 1
Thanks: 0
skimsen is on a distinguished road
Default Help requested

I have a problem same as reported here

I updated the httpd.conf file to set AllowOverride ALL and then i get the internal 500 server error.
My mod_rewrite module is loaded. But none of the rewrite rules work. all result in an error.

Can one of your experts please advise?
thanks
Sonali
skimsen is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 07:32 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design