ModRewrite remove /index.php/ - apache

I've got old urls and want to remove the /index.php/ via .htaccess:
So old url is:
www.mysite.com/index.php/onesite.html
rewrite in .htaccess into
www.mysite.com/onesite.html
How can I do that?
Thx for your help

Adding the following code to your htaccess will allow this
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index.php/(.*)$ www.mysite.com/$1 [R=302,L]
Changing 302 to 301 when you are sure the redirect is working

Try this one:
RewriteRule ^index.php/(.*?)$ http://%{HTTP_HOST}/$1 [R=301,L]

Just add this in your .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
If you site is in subfolder then
<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 these 2 rules in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^index\.php(/.*)?$ $1 [L,R=301,NC,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)/?$ /index.php/$1 [L]

Related

issue redirecting http to https

I'm trying to enforce https for all traffic and I've tried to add the following lines to .htaccess:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]`
The issue is that the current .htaccess file already has the following code:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php [NC,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
I combined both as follows:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteRule ^(.*)$ index.php [NC,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Unfortunately, this is not working out. I'm getting a redirect loop error... Thanks in advance for your help.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} =off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ index.php [L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

Redirect to internal path .htaccess

I just want to redirect from
mydomain.com/foo
to
mydomain.com/foo/bar
My root .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Any simple answer would be pretty appreciated.
You need to add RewriteRule ^foo/?$ /foo/bar [R=302,L] to the rewrites:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^foo/?$ /foo/bar [R=302,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Apache Htaccess rewrite rules

I have to write a htaccess to rewrite the links as follows and also a redirection of 404
error pages to my sites root (home page)
www.example.com/index.php?page=find&name=detail&id=109&cid=8
www.example.com/index.php?page=find&name=detail&id=109
www.example.com/index.php?page=find&name=detail
www.example.com/index.php?page=find
should be rewritten to
www.example.com/find/name/detail/id/109/cid/8
www.example.com/find/name/detail/id/109
www.example.com/find/name/detail
www.example.com/find
Your htaccess rules,
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?file=$1 [L,QSA]
RewriteRule ^([a-zA-Z]+)/page/([a-zA-Z]+)/id/([0-9]+)/cid/([0-9]+)/$ index.php?page=find&name=detail&id=109&cid=8 [L]
RewriteRule ^([a-zA-Z]+)/page/([a-zA-Z]+)/id/([0-9]+)/$ index.php?page=find&name=detail&id=109 [L]
RewriteRule ^([a-zA-Z]+)/page/([a-zA-Z]+)/$ index.php?page=find&name=detail [L]
RewriteRule ^([a-zA-Z]+)/$ index.php?page=find [L]
</IfModule>
Try:
RewriteEngine On
RewriteRule ^find$ index.php?page=find [L,QSA]
RewriteRule ^(find)/([^/]+)/([^/]+)(.*)$ /$1$4?$2=$3 [L,QSA]
FallbackResource /
Try this code:
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule (.*)/([a-zA-z0-9]*)/(.*)/([a-zA-z0-9]*)/(.*)/([a-zA-z0-9]*)/(.*)/([a-zA-z0-9]*)/(.*)\.html index.php?itfpage=$1&$2=$3&$4=$5&$6=$7$8=$9 [L]
RewriteRule (.*)/([a-zA-z0-9]*)/(.*)/([a-zA-z0-9]*)/(.*)/([a-zA-z0-9]*)/(.*)\.html index.php?itfpage=$1&$2=$3&$4=$5&$6=$7 [L]
RewriteRule (.*)/([a-zA-z0-9]*)/(.*)/([a-zA-z0-9]*)/(.*)\.html index.php?itfpage=$1&$2=$3&$4=$5 [L]
RewriteRule (.*)/([a-zA-Z]*)/(.*)\.html index.php?itfpage=$1&$2=$3 [L]

.htaccess Rewrite mod not working

I'm trying to get my htaccess file to use this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
to rewrite this url:
http://cheesecakebb.org/index.php?action=vn
Try this instead:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index/([^/]+)/?$ index.php?action=$1 [QSA,L]
When someone clicks example.com/index/something, it will redirect (invisibly to the user) to index.php?action=something

.htaccess Apache URL Rewrite for Wordpress - permanently pointing one domain to another

I am trying to point www.olddomain.com/whatever to www.newdomain.com/whatever (as well as without the www.), but the Wordpress permalinks are not staying intact. Please help!!
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} ^olddomain.com [nc]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [r=301,nc]
RewriteCond %{HTTP_HOST} ^www.olddomain.com [nc]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [r=301,nc]
</IfModule>
I fixed it:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^olddomain.com [nc]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [r=301,nc,L]
RewriteCond %{HTTP_HOST} ^www.olddomain.com [nc]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [r=301,nc,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
A much simpler solution. Change the .htaccess to just say:
RedirectMatch 301 /(.*) http://www.newdomain.com/$1
You will need to move this block:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
behind the redirects. It grabs everything and sends it to index.php.