How to avoid a redirect? - wordpress

I have two similar wordpress websites.
http://site.com/ and http://site.com/en/
When I try to load http://site.com/en/page1.php then it redirects automatically on to http://site.com/page1.php
Seems, I have to change rewrite rule in the htaccess.
http://site.com/ has htaccess with a content whithin:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^en/.*$ en/index.php [L]
#RewriteRule . /index.php [L]
</IfModule>
# END WordPress
The second one is (for http://site.com/en/):
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /en/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Which rule I should write here to work that?

I solved it.
It should be like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /en/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /en/index.php [L]
</IfModule>
# END WordPress

Related

Wordpress own RewriteRule doesn't work

When I write my.domain/my/url I want to go to other webpage, but I am still on
my.domain/my/url with Error 404
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# Here is my RewriteRule
RewriteRule ^my/url$ //google.pl
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Here is the answer for your htaccess issue. You need to add the folders in the RewriteBase like i did. For example www.domain.com/my/url/ is path of your wordpress then you need to add /my/url/ to rewritebase.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /my/url/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
</IfModule>
# END WordPress

Wordpress .htaccess RewriteRule

does someone know why the imprint rewrite rule does not work?
It does not show the imprint-custom page.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^imprint/(.*)$ imprint-custom/$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

.htaccess file for wordpress example.com/blog redirecting to example.com

My website at www.tripfelt.com uses the .htaccess below to handle pretty URLs:
Options +FollowSymLinks
# enable rewrite engine
RewriteEngine On
RewriteRule ^blog - [L,NC]
RewriteRule ^robots.txt - [L]
RewriteRule ^$ index.php?/ [QSA,L]
RewriteCond %{REQUEST_URI} !^/blog
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?/$1 [QSA,L]
www.tripfelt.com/blog uses the following .htaccess:
# 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
However, clicking on any blog item, instead of opening the blog story, is redirecting to the main site. Any ideas what I am doing wrong?
Try changing the base in your blog folder to /blog/ and remove the leading slash in the routing rule:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
Solved
Blog folder
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress

wordpress rewriting in .htaccess to example.de/anmelden/

in my .htaccess is the following rewrite (standard-)rule:
# 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
how can modify this, that the url example.de (http and https) route to https://example.de/anmelden/
Thank you! Cheers Marco
This should work for you.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index\.php(.*)$ /anmelden/index.php$1 [L]
</IfModule>
# END WordPress
You can also try:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /anmelden
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
One More
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/(gadget)/(.*) /gadget/$2 [R]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Try this code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+[?\s]
RewriteRule /anmelden/ [L,R]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
You should be able to use
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /anmelden
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Static Url Redirection in Wordpress

I need to redirect page1 to something/page1 in my wordpress site.
i have tried the below rule in my htaccess file.
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^page1/$ something/page1? [L]
</IfModule>
# END WordPress
i am not familiar in htaccess rules. but the redirection is not working.
can any one help me?
Thanks
Maybe this will work:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Next line added
RewriteCond %{REQUEST_URI} !page1 [NC]
RewriteRule . /index.php [L]
# Next 3 lines added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^page1 something/page1? [L]
</IfModule>
# END WordPress
For permanent and visible redirection, replace [L] with [R=301,L] in the last rewrite rule.

Resources