htaccess
-
Hi there,
i have a question how can i redirect with rewriterule wordpress page/post to external webpage
Thanks for tips.
-
Try this plugin:
Hi mocco. Can you give us a specific example of what you’re trying to do? For example, do you want http://domain.com/category/post to redirect to http://otherdomain.com ?
You may want to try:
RewriteCond %{HTTP_HOST} ^whhsupport.com$ [OR] RewriteCond %{HTTP_HOST} ^www.whhsupport.com$ RewriteRule ^category\/post$ "http\:\/\/otherdomain\.com" [R=301,L]
example
hxxp://www.bestsponsors.info/sample-page/ to hxxp://www.google.com
RewriteCond %{HTTP_user_agent} googlebot^$ [NC]
RewriteRule ^sample-page/$ “http\:\/\/google\.com” [NC,L]is that right ?
And equalmark
I want to do this in htaccess. Without wordpress plugins. but thank you for your help.
You may want to try this:
RewriteCond %{HTTP_HOST} ^bestsponsors.info$ [OR]
RewriteCond %{HTTP_HOST} ^www.bestsponsors.info$
RewriteRule ^sample-page$ “http\:\/\/google\.com” [R=301,L]not working :/
Try removing the escapes (escapes are not needed in url):
RewriteRule ^sample-page$ “http\:\/\/google\.com” [R=301,L]
to this (all you need is the exact URL that you’re directing them to) (there is a difference between external and internal redirects, so I’m not sure what you’re exactly trying to do):
RewriteRule .* http://google.com/ [L]
So try this:
RewriteCond %{REQUEST_URI} ^http://www.bestsponsors.info/sample-page/$ [NC]
RewriteRule .* http://google.com/ [NC,L]or
RewriteCond %{THE_REQUEST} ^http://www.bestsponsors.info/sample-page/$ [NC]
RewriteRule .* http://google.com/ [NC,L]Remove the $ symbol if you don’t want to be that specific, for exmaple if you’re wanting to including sub-directories, etc that need to be redirected as well.
oops forgot the HTTP_user_agent. I believe it needs some adjusting as well. The way you have it, it states user agent googlebot blank. The blank be provided by ^$. I would just do it like the following, moving the ^ to the front of googlebot and removing the $ as you may not want to be that specific.
Try these:
RewriteCond %{HTTP_user_agent} ^googlebot [NC]
RewriteCond %{REQUEST_URI} ^http://www.bestsponsors.info/sample-page/$ [NC]
RewriteRule .* http://google.com/ [NC,L]or
RewriteCond %{HTTP_user_agent} ^googlebot [NC]
RewriteCond %{THE_REQUEST} ^http://www.bestsponsors.info/sample-page/$ [NC]
RewriteRule .* http://google.com/ [NC,L]What this states is, if the user agent is googlebot (including variants) and they are requesting the specific page (remove the $ if you do not want it to be that specific), then send them to the RewriteRule.
RewriteCond %{HTTP_user_agent} ^googlebot [NC] RewriteCond %{REQUEST_URI} ^http://www.bestsponsors.info/sample-page/$ [NC] RewriteRule .* http://google.com/ [NC,L]
or
RewriteCond %{HTTP_user_agent} ^googlebot [NC] RewriteCond %{THE_REQUEST} ^http://www.bestsponsors.info/sample-page/$ [NC] RewriteRule .* http://google.com/ [NC,L]
If neither of those work, try this (HTTP_HOST may be required):
RewriteCond %{HTTP_user_agent} ^googlebot [NC] RewriteCond %{HTTP_HOST} ^http://www.bestsponsors.info/sample-page/$ [NC] RewriteRule .* http://google.com/ [NC,L]
solution that worked for me:
#RewriteCond %{REQUEST_URI} ^/sample-page/ [NC] #RewriteRule ^.*$ http://www.google.com [R=301,L]
Thank for help!
- The topic ‘htaccess’ is closed to new replies.