Results 1 to 8 of 8
-
02-08-2012, 03:46 PM #1Junior Guru Wannabe
- Join Date
- Dec 2009
- Posts
- 38
RewriteRule. Why it doesn't work?
Hi!
I'm trying to set up a rewriterule on my server, but it always returns the number 404 error (not found). The $1 placed on the end of the line is not working. Why?
The rule:
RewriteRule !^(admin|padrao|blog)/(.*) /padrao/$1\.php [L]<<< Please see Forum Guidelines for signature setup. >>>
-
02-08-2012, 06:29 PM #2Newbie
- Join Date
- Feb 2012
- Posts
- 24
Try
RewriteRule !^(admin|padrao|blog)/(.*)$ /padrao/$1\.php [L]
-
02-08-2012, 06:56 PM #3Newbie
- Join Date
- Feb 2012
- Posts
- 24
Sorry, the one before does not work.
RewriteRule ^((?!(admin|padrao|blog)\/)(.*))\/(.*)$ /padrao/$1\.php [L]
-
02-09-2012, 02:43 AM #4Retired Moderator
- Join Date
- Feb 2005
- Location
- Australia
- Posts
- 5,849
Probably because your rule says that the request should not match the regexp, and then you're trying to extract the part ($1) that matches.
This is untested but something like it should do what you want:
Code:RewriteCond %{REQUEST_URI} !^(admin|padrao|blog) RewriteRule (.*) /padrao/$1\.php [L]
Last edited by foobic; 02-09-2012 at 02:46 AM. Reason: Simplified
Chris
"Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter
-
02-09-2012, 08:42 AM #5Newbie
- Join Date
- Jan 2012
- Location
- Copenhagen, Denmark
- Posts
- 20
i have some different problem, first I am rewriting site to www for desktop version and then I have mobile site as well, I am rewriting to mobile, until url alias is working.
But if inside url is rewriting from desktop to mobile like sitename*com/about to m.sitename*com/about its url alias goes very bad. something like m.sitename*com/querypage?querypage?about
any one have any idea?
regards
Nyssa
-
02-09-2012, 09:43 AM #6Junior Guru Wannabe
- Join Date
- Dec 2009
- Posts
- 38
Almost perfect! There is only one problem: I always need to put a "/" on the end of the URL. Like this: www.site.com/something doesn't match. But www.site.com/something/ works
<<< Please see Forum Guidelines for signature setup. >>>
-
02-09-2012, 11:25 AM #7Junior Guru Wannabe
- Join Date
- Dec 2009
- Posts
- 38
<<< Please see Forum Guidelines for signature setup. >>>
-
02-09-2012, 01:54 PM #8Newbie
- Join Date
- Feb 2012
- Posts
- 24
To have / at the end, insert \/ right before $.
$ means match the end of string
So something like
^[0-9]+$ would match 100, but not 100a
Similar Threads
-
cp -f doesn't work?
By twrs in forum Hosting Security and TechnologyReplies: 14Last Post: 07-20-2011, 11:13 AM -
Why doesn't mod_rewrite always work the same?
By lexington in forum Programming DiscussionReplies: 0Last Post: 07-01-2011, 05:46 AM -
My server doesn't support RewriteRule
By SLiM_BoY in forum Hosting Security and TechnologyReplies: 1Last Post: 08-18-2006, 07:14 AM -
Why won't this code work? - RewriteCond/RewriteRule
By MaxS in forum Programming DiscussionReplies: 4Last Post: 11-11-2005, 10:16 AM