Hi I am looking to the following in .htaccess:
RewriteRule ^pqr$ /pqr.php
[without 301 redirect, because I want the user to see "pqr" in the broswer and not "pqr.php"]
The problem is that when I try the above .htaccess code, /pqr automatically redirects to the "pqr" subdirectory (/pqr/). I'm looking for a way to stop that automatic redirection.
Do you know how to do that with htaccess?
my current htaccess code
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /Wordpress_Work/placewise/wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /Wordpress_Work/placewise/wordpress/index.php [L]
</IfModule>
# END WordPress
That should do it:
RewriteEngine on
RewriteRule ^/([^/\.]+)/?$ $1.php [L]
Related
I have a page locally that is /shop but I want it to redirect to /shop/designs
I tried to do it with .htaccess but nothing seems to be working.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/shop/.*$ /shop/designs/ [R=301,L]
# 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 where I am going wrong?
You were almost there, but in htaccess, you cannot use / at the beginning of the path regex.
Change your rule like so:
RewriteEngine On
RewriteRule ^shop$ shop/designs [R=301,L]
I've moved my site with all its contents from the root to a subfolder, like
www.example.com
To
www.example.com/shop
Now, I want to redirect all old pages to the new url.
What I tried in the .htaccess of the root, but did'nt work:
RewriteEngine On
RewriteRule ^(shop)($|/) - [L] // To prevent loops
RewriteRule ^(.*)$ http://www.example.com/shop$1 [R=301,L]
But now, all old pages redirect to example.com/shop
Edit:
After it was moved, I had to add following code to the htaccess of subdirectory to make it work:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /shop/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]
</IfModule>
You can use this rule:
RewriteEngine On
RewriteCond %{THE_REQUEST} !/shop/ [NC]
RewriteRule !^shop/ /shop%{REQUEST_URI} [NC,R=301,L]
I am using wordpress and need to redirect wp-login?action=register to /registration/ page,
first i did
Redirect /wp-login.php http://www.class-world.com/register/
but then it also keeps redirecting logout wp-login.php?action=logout so cant logout at all.
My question is how to only redirect action=register, instead of whole wp-login.php
I tried with following:
RewriteRule ^/wp-login.php\?action=register$ /register/
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^/wp-login.php\?action=register$ /register/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
but no luck
Try this code :
RewriteEngine On
RewriteCond %{QUERY_STRING} ^action=register
RewriteRule ^wp-login\.php$ /register/ [R=301]
I tried googling this problem about a site do not open without www in chrome, But it works on other browser, here's my .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule ^(.*)$ "http\:\/\/www\.mydomain\.com\/$1" [R=301,L]
# 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
You have mistake in your .htaccess file. You activate rewrite engine twice. Your .htaccess file has to be like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule ^(.*)$ "http\:\/\/www\.mydomain\.com\/$1" [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Update:
You can't open your site in chrome without www. because your .htaccess file contains redirection rule, what redirects your visitors from mydomain.com to www.mydomain.com. This rule is used for SEO, read through Redirection SEO Best Practices article (especially Redirecting Canonical Hostnames paragraph) to become more familiar with it.
I have a blog set up at blog.ftj.com/ACSM, it is hosted with Bluehost and their folder structures seem to be case sensitive. Is there something in the .htaccess file that I can adjust so that all possible combinations get redirected to the specific uppercase URL.
Another issue is that it seems that I need to redirect
blog.ftj.com/acsm/
with and without the forward slash.
Here is my current .htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ACSM/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ACSM/index.php [L]
</IfModule>
# END WordPress
Please submit the full change if you would.
You need to place the following .htaccess in the root dir to rewrite all requests to /ACSM into /acsm
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/acsm$ [NC]
RewriteRule ^(.*)$ /ACSM [L]
RewriteCond %{REQUEST_URI} ^/acsm/(.*)$ [NC]
RewriteRule ^acsm/(.*)$ /ACSM/$1 [L]
</IfModule>
Sorry for delays, have not got an Apache at hands....