How to get this rewrite rule working?

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

How to get this rewrite rule working?

Post by lovelf »

rewrite rule:

Options +FollowSymlinks

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^search/(.*)$ http://www.domain.com/search/?term=$1
I want all search/my_search to go to search/?term=my_search silently

Thanks
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How to get this rewrite rule working?

Post by requinix »

And the problem is... that it's not silent? But otherwise works?
User avatar
Celauran
Moderator
Posts: 6425
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to get this rewrite rule working?

Post by Celauran »

By matching everything after search/ and redirecting it to a URL containing search/, you have created an infinite loop. I'd have thought matching everything except a question mark (ie. ([^\?]+)) would work, but that still redirects forever. This isn't perfect, but it works.

Code: Select all

RewriteRule ^search/([a-zA-Z0-9\-_\+\s]+)$ search/?term=$1 [L]
KarlRice
Forum Newbie
Posts: 2
Joined: Sun Aug 10, 2014 11:16 pm

Re: How to get this rewrite rule working?

Post by KarlRice »

Hay friend
Try it for getting the rewrite rule working
RewriteEngine on
RewriteCond %{HTTP_HOST} ^cp.abc.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.cp.abc.com$
RewriteRule ^/?$ "http\:\/\/cp\.xyz\.com" [R=301,L]

I have also ensured IP and document root path on both subdomains under /var/cpanel/userdata/username/ directory and it is correct.

Thank you
Post Reply