works on local machine, not on hostingserver.

Oh, the strange things mod_rewrite does!

works on local machine, not on hostingserver.

Postby musti » Tue May 10, 2005 11:10 am

my local machine has: [Apache/2.0.52 | PHP/5.0.3]
my hostingserver has: [Apache/1.3.29 | PHP/4.3.10]


I have the following rule in my .htaccess

RewriteRule ^([a-z0-9\-\/]+)(/)$ /index.php?pagina=$1

This should search for a string which has either " numbers, text, / or -" and ends with a "/"

As stated in the topic, this works fine on my local machine.

On the hostingserver, all seems to work until this rule encouters a string, formatted as such: "string-2004".
When serving this to the mod-rewrite, I get a 404

anyone got a solution to this problem?
Thx in advance
musti
 
Posts: 1
Joined: Tue May 10, 2005 11:05 am

Postby Caterham » Wed May 11, 2005 1:32 pm

althow the RegEx should work..
We can remove the backslashes, if we change the order of the character class
Code: Select all
RewriteEngine On
RewriteRule ^([a-z0-9/-]+)/$ /index.php?pagina=$1 [NC,L]


I assume that this works:

RewriteRule ^.* http://www.cnn.om [R,L]
?
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Guest » Fri May 13, 2005 7:37 am

thx for the help
it works now :)
Guest
 

Postby Neo » Thu Nov 30, 2006 5:37 pm

I'm having a similar issue, i have this rule:
Code: Select all
RewriteRule ([0-9]+)/([A-Z_\-a-z\']+)$ index.php?cat_id=$1&catname=$2

and have rewritten it after i saw this post to this:
Code: Select all
RewriteRule ([0-9]+)/([A-Z_a-z-]+)$ index.php?cat_id=$1&catname=$2

However I still need to have the
Code: Select all
'
in my rule in order to make the script im working with working correctly. How can I go about that?
Neo
 
Posts: 3
Joined: Wed Sep 27, 2006 3:46 pm

Postby richardk » Fri Dec 01, 2006 9:43 am

Use [^/]:
Code: Select all
RewriteRule ^([0-9]+)/([^/]+)$ /index.php?cat_id=$1&catname=$2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Neo » Sat Dec 02, 2006 12:50 am

Thanks a lot Richardk
Neo
 
Posts: 3
Joined: Wed Sep 27, 2006 3:46 pm


Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 2 guests

cron