I want to ask is it correct the way that I add 410 to page in .htaccess in Wordpress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule http://exapmle.com/%D1%8BB%D1%83%D0%B3%D0%B8/ [G=410,L]
RewriteRule http://example.com/%D0%%D1%82%D0%B0%D0%BA%D1%82%D0%B8/ [G=410,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Thank you!
you don't want the http://example.com part in the pattern, that's not part of the URI that's used for the pattern to match against
You don't need the =410 in the flags
The URI is already decoded by the time mod_rewrite rules get applied, so you don't want (I'm assuming) the URL encoded string.
Try:
RewriteRule ^ыBуги/ - [G,L]
RewriteRule ^ÐÑакÑи/ - [G,L]
If you want to show "Gone" error for those 2 URLs (mentioned in your code) then put this code right on top of .htaccess after RewriteBase line:
RewriteRule ^\xD1\x8BB\xD1\x83\xD0\xB3\xD0\xB8/?$ - [G,L]
RewriteRule ^\xD0\xD1\x82\xD0\xB0\xD0\xBA\xD1\x82\xD0\xB8/?$ - [G,L]
Do you mean:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/%D1%83%D1%81%D0%BB%D1%B3%D0%B8/ - [G,L]
RewriteRule ^/%D0%B7%D0%0%BE%D0%BD%D1%82%D0%B0%D0%BA%D1%82%D0%B8/ - [G,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPdpress
or to put these two lines of URLs at the top ot the .htaccess file, outside of:
# BEGIN WordPress
Related
I have a scenario where I need to redirect all URLs or wordpress without trailing post id using .htaccess
Example:
https://example.com/chapter/subject-origin-chapter/1223 to https://example.com/chapter/subject-origin-chapter
and
https://example.com/subject/subject-physics/38957 to https://example.com/subject/subject-physics
Other solutions are also welcome.
Current .htaccess is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I found a solution as:
RewriteRule ^chapter/([a-zA-Z0-9-]+)/(\d+)$ /chapter/$1 [L, R=301]
RewriteRule ^subject/([a-zA-Z0-9-]+)/(\d+)$ /subject/$1 [L, R=301]
I know there are a lot of threads for .htaccess URL rewriting, but my case seems to be a bit different and I have tried a lot but it doesn't work.
My current URL: http://example.com/forest/trees/?type=perennial
What I need is: http://example.com/forest/trees/perennial
I just need to remove the ?type= from the URL.
EDIT: The URL may contain hyphens - between strings at any point (except the domain name ofcourse). It can be dense-forest or non-perennial too.
It's a custom code and plugin, so can't modify it. I just need the URL beautified.
Any help would be greatly appreciated.
What I've tried so far in .htaccess:
RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD)\ /forest\/trees\/\?type=([^&]+)
RewriteRule ^ \/forest\/trees\/%2\/? [L,R=301]
and
RewriteRule ^\/forest\/trees\/([^/]*)? /forest/trees/?type=$1 [L]
My current Wordpress .htaccess is:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Thanks in advance. :)
Cheers!
You can use this .htaccess file:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^forest/trees/([^/]+)$ /forest/trees/?type=$1
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Now URLs like http://example.com/forest/trees/perennial will internally redirect to /forest/trees/?type=perennial and then to Wordpress Dispatcher /index.php.
I'm using wordpress for a site,
this url before tes.com/index.php/about/
i want url like this tes.com/about/
I have tried copying parts of WordPress' .htaccess, however shows a 404 error.
My .htaccess file looks like:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Any ideas on where to start and how to accomplish what I'm looking for?
Go to your WP-ADMIN-->Settings-->Permalink and use the permalink structure change there, if it generate any .htaccess file copy the content and update your .htaccess file.
Or Check if your hosting mod_rewrite is enable by creating a file phpinfo.php with content,
Upload this file and browse via Browser. So you know which modules are enabled. You need mod_rewrite enable to remove index.php from URL.
Try this -
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test.com/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test.com/index.php [L]
</IfModule>
The official instructions will give you clean urls. So best to follow this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I am trying to redirect using a .htaccess file and it's not working. The syntax seems to be correct. Does any one have any ideas what is incorrect?
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Redirect 301 /www.easycovertarp.com/ http://www.aeroindustries.com/products/easy-cover/
Insert this rule just below RewriteBase line:
RewriteCond %{HTTP_HOST} =local.aero.com
RewriteRule ^/?$ http://www.aeroindustries.com/products/easy-cover/ [L,R=301]
Ordering is important in mod_rewrite rules so this rule must be placed above shown WP rules.
I had the page name as the-book.html, but now i changed the page name to about-the-book. I have used the rewrite rule as
`Redirect 301 /the-book.html http://www.xxx.com/about-the-book.html`
but it is not working.
my full .htaccess code is here
RewriteRule ^/the-book.html$ http://www.xxx.com/about-the-book.html [R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteRule ^the-book.html$ http://www.example.com/about-the-book.html [R=301]
Not sure about the Redirect directive, but
RewriteRule ^the-book.html$ http://www.xxx.com/about-the-book.html [R=301]
should work nicely.
Edit:
Removed the leading / in the match part.