I want to redirect the some urls to others using the htaccess file. I want to show
http://test.com/news/david-highlights-unsung-community-hero/
when someone open the url
http://test.com/index.php?process=views/article.php&articleId=44102
using the htaccess file. Please let me know how I can rewrite the rule for such urls in htaccess file.
If you want to redirect that exact URL using htaccess, you can do this.
redirect /index.php?process=views/article.php&articleId=44102 http://test.com/news/david-highlights-unsung-community-hero/
For more information, visit: http://webmaster.iu.edu/tools-and-guides/maintenance/redirect-htaccess.phtml
*Please let me know how I can rewrite the rule for such urls in htaccess file.
In your .htaccess file add:
`Redirect 301 /news/david-highlights-unsung-community-hero/ http://test.com/index.php?process=views/article.php&articleId=44102`
OR
`Redirect 302 /news/david-highlights-unsung-community-hero/ http://test.com/index.php?process=views/article.php&articleId=44102`
302 redirects are good if you will do SEO for your site later, 301 redirects are permanent, Or you can use ' preety link ' wordpress plugin to get this done from wordpress admin panel.
put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^process=views/article\.php&articleId=44102$ [NC]
RewriteRule ^index\.php$ /david-highlights-unsung-community-hero/? [L,NC,R=301]
Related
I have a url structure as xxxx.com/blog/page/1. But pagination gives 404. I need to rewrite it with .htaccess as xxxx.com/blog?page=1. Can you help me?
RewriteRule ^blog/page/([0-9]+)$ blog?page=$1 [R=302,L]
i try this rule in htaccess
I am trying to redirect my all old Wordpress website url to a new WordPress website. I am able to redirect the main url but my i am not able to redirect the internal pages url. Can you please help. This is what i used to redirect the old url to the new one.
Redirect 301 / https://test1.com/subfolder/
This one is working fine but i need to redirect https://test.com/subfolder/page1 to https://test1.com/subfolder/page1. Currently this link (https://test.com/subfolder/page1) is also redirecting to the https://test1.com/subfolder/
Insert this rule just below RewriteEngine On line:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?test\.com$ [NC]
RewriteRule ^ https://test1.com%{REQUEST_URI} [L,NE,R=301]
# rest of the rules go here
You must clear your browser cache before testing this change.
I have very weird problem.
My WordPress site gets traffic to the same page with different additional parameters.
Example:
mysite.com/page1.html?m=1
mysite.com/page1.html
It is the same page, but ?m=1 makes WP show 404 error page.
I tried 301 redirect like this (in actual HTACCESS file i also use http:// but here I cannot):
Redirect 301 /page1.html?m=1 mysite.com/page1.html
But this does not do anything.
Traffic comes from google, so I cannot change this URL structure - I have to work with what I got ... So how I fix this???
It could be either WP or HTACCESS problem ... I searched and cannot find anything - i get results for M1 rifle :(
Please help - this is a live site
You can't match against the query string in mod_alias's Redirect or RedirectMatch. You need to use mod_rewrite's %{QUERY_STRING} or %{THE_REQUEST} variables. Try:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^m=1$
RewriteRule ^(.*)$ /$1? [L,R=301]
This will redirect any request that has the "m=1" query string and remove it.
.htaccess
RewriteEngine On
RedirectMatch 301 ^/page1.html?m=1$ /page1.html
Try that see also this answer .htaccess 301 redirect of single page
I have troubles with mod_rewrite.
I have wordpress site located in 'wp' directory. It is accessible as http://localhost/wp/
There is page http://localhost/wp/sample-page/ on the site.
I want to make this page open with url http://localhost/wp/sample-page-2/ without redirect.
Here is what in .htaccess file:
RewriteEngine On
RewriteBase /wp/
RewriteRule ^sample-page-2/$ sample-page/ [L]
But I'm getting 404 error.
Could somebody explain me what I'm doing wrong?
Thanks in advance.
UPD:
#soju: Well, "sample-page-2" - is just example
It is not a page/post in worpress sence.
Actually I tried to add one section to the url. E.g. http://localhost/wp/sample-page/section/. And this rule RewriteRule ^sample-page/section/$ sample-page/ [L] didn't work. Then I decided to "simpliyfy" url("sample-page-2" instead of "sample-page/section") - no success.
UPD2
BTW, redirect RewriteRule ^sample-page-2/$ sample-page/ [R=301,L] works
I suppose wordpress rewrite rules are after your own rule, so you should remove [L] option to let wordpress handle sample-page url
EDIT about UPD2 : Well, it works with a 301 redirection, but you said you don't want redirection ?
You can add a filter on rewrite_rules_array to make your own rewrite rule, take a look at example on codex : http://codex.wordpress.org/Class_Reference/WP_Rewrite#Examples
I'm working with a redirection plugin in Wordpress that accepts regex and I want to 301 an entire directory to something new.
http://www.example.com/tag/exampletag1/ &
http://www.example.com/tag/exampletag2/
to
http://www.example.com/music/exampletag1/ &
http://www.example.com/music/exampletag2/
Is this possible? There are quite a few tags so I don't want to do this manually. Would this be easier to do in the htaccess file?
Anything that will get me going in the right direction is great.
The following ruleset in .htaccess would redirect /tag/ to /music/
RewriteEngine On
RewriteRule ^/tag/(.*) /music/$1 [R=301]
[R=301] indicates an external redirect with HTTP status code 301.