Forum Moderators: phranque
(.*) pattern unless it is the LAST element before the $ end anchor. (.*) says "read the entire request into the $1 backreference". (.*)-me says "read the entire request into the $1 backreference then follow it with -me". This means the parser has to back off and retry hundreds of matches to see what you actually meant: when you said "all" you didn't actually mean "all". ([^/]+)/updates/latest-news/([^-]+)(-me.*) which means "read until the next slash", then read "update/latest-news/" then "read until the next hyphen" followed by "me and the rest of the string". so I amend to
([^-me]+) so it retries until it reaches the final 'h' then follow with (-me.*)
Without RewriteBase / i'm getting the server directories on redirect at the front of the directories I want.
http://example.com/...something/something/public-html/...article-search/item... blah
RewriteRule ^updates/admission-news/(([^-]+(-[^-]+)+)-[^-]+)$ article-search/item/$1 [R=301,L]
to catch a URL that has something like .../updates/admission-news/filename
Oh, lord, I'm getting a headache. You mean after all that business with hyphens, you now need to capture addresses that don't have hyphens at all? This isn't the thread where they were trying to capture the query string was it? So far, nothing you're doing has had any effect on the query. The rewrite stashes the query-- if any-- in a back room, does all of its stuff, and then quietly reappends it unchanged.
.../path/path?tabslider=tab180_212&tstype=tabslider_ajax&tstype=tabslider_ajax&tabslider=tab178_212 If you want to do anything at all with query strings you need a preceding RewriteCond to check the value of either %{QUERY_STRING} or %{THE_REQUEST}
RewriteRule ^forum/forumdisplay\.php$ forum/forum\.php [R=301,L] I've got bogged down with this and now can't see why I can't even do another simple redirect with:
^forum/forumdisplay\.php$ forum/forum\.php [R=301,L]
I do however have some URLs that have hyphens and at the end there is something like this but is random with regard to the directory structure/path:
.../path/path?tabslider=tab180_212&tstype=tabslider_ajax&tstype=tabslider_ajax&tabslider=tab178_212
Is this a whole new question? The original problem was how to chop off the -me or -dp or whatever at the very end of the URL. What are you trying to do with the ones that don't require chopping?
Get rid of that second \.php escape. The target part of a rewrite isn't a RegEx, so it's trying to go to a page whose actual url has a backslash in it.
Did you mean that you've got some spurious urls where the formula is
{blahblah}/{somestuff}/{the exact same stuff again}
? And you need to get rid of the duplicated part?
http://www.example.com/articles/editorial/an-interesting-page http://www.example.com/articles/editorial/an-interesting-page?tabslider=tab180_212&tstype=tabslider_ajax&tstype=tabslider_ajax&tabslider=tab178_212 (([^-]+(-[^-]+)+)-[^-]+(.*))
Get rid of that second \.php escape. The target part of a rewrite isn't a RegEx, so it's trying to go to a page whose actual URL has a backslash in it.
Get rid of that second \.php escape. The target part of an internal rewrite isn't a Regular Expression, it's a real filename on the server hard drive. It's trying to retrieve a file whose actual filename has a backslash in it.
I have 2 URLs
http://www.example.com/articles/editorial/an-interesting-page
http://www.example.com/articles/editorial/an-interesting-page?tabslider=tab180_212&tstype=tabslider_ajax&tstype=tabslider_ajax&tabslider=tab178_212
so I wanted to get rid of the second one by 301 redirecting to the first.
When you want to erase an existing query string, end the substitution string with just a question mark.
Add the protocol and domain name to the RewriteRule target and you're there.
www.example.com/old-page redirects to www.example.com/new-page example.com/old-page redirects to example.com/new-page Without the domain name in place in the redirect target,
www.example.com/old-page redirects to www.example.com/new-page
and example.com/old-page redirects to example.com/new-page
thereby promoting Duplicate Content.
If you have a separate non-www to www redirect in place, you will also have created an unwanted two-step redirection chain for all non-www requests.