htaccess hide subdirectory with RewriteBase - .htaccess

From
http://www.example.com/eblasts/_ire
To
http://www.example.com/eblasts
I have this, but doesn't work...
RewriteBase /
RewriteCond %{REQUEST_URI} !^/eblasts/_ire
RewriteRule ^(.*)$ eblasts/$1 [L]
What did I mess up on?

your rewriterule rewrite http://www.example.com/eblasts/_ire to http://www.example.com/eblasts/eblasts/_ire
RewriteBase /
RewriteCond %{REQUEST_URI} !^/eblasts/_ire
RewriteRule ^(.*)$ eblasts [L]
Update:
RewriteRule ^home.html$ _ire/home.html

Related

Rewrite trailing slash everywhere

I am having problems with my .htaccess file.
It looks like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^website\.de [NC]
RewriteRule ^(.*)$ http://www.website.de/folder/$1 [L,R=301]
RewriteRule ^traffic/?$ traffic.php [NC,L]
RewriteRule ^what-if/?$ whatif.php [NC,L]
If I call www.website.de/folder/traffic I get www.website.de/folder/traffic/.
But if I call www.website.de/folder/what-if the trailing / is missing.
How can I add it everywhere?
You have to specify a RewriteBase since your htaccess is in a subfolder.
Also, you have to disable MultiViews option to avoid the problem you have.
Options -MultiViews
RewriteEngine On
RewriteBase /folder/
RewriteCond %{HTTP_HOST} ^website\.de$ [NC]
RewriteRule ^(.*)$ http://www.website.de/folder/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.+)$ $1/ [R=301,L]
RewriteRule ^traffic/$ traffic.php [NC,L]
RewriteRule ^what-if/$ whatif.php [NC,L]

.htaccess redirect example.com/magento/index.php to example.com/?

I have Magento installed in a subdirectory, the path to Magento is example.com/magento.
I have an .htaccess file in the root, 'example.com' as follows:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{http_host} ^example.com [NC]
RewriteRule ^magento/(.+)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/magento(/.*)?$ [NC]
RewriteRule ^(.*)$ /magento/$1 [QSA,L]
In the standard Magento .htaccess in example.com/magento I have uncommented the RewriteBase directive as follows:
RewriteBase /magento/
But when I type example.com the browser shows example.com/magento
How could I solve this issue?
Leave RewriteBase commented
# RewriteBase /magento/
Try this, instead, in your /.htacccess:
RewriteEngine on
RewriteRule ^(.*)$ /magento/$1 [L]
RewriteRule ^(.*)$ /index.php/$1 [L]
and add this to your magento/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . / [L]
</IfModule>

Create SEO Friendly URLS doesn't work (.htaccess)

I created an htaccess i want to rename all extension .php files to .html
i put
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} (.*)\.php
RewriteRule ^(.*)\.php $1.html [R=301,L]
RewriteCond %{THE_REQUEST} (.*)\.html
RewriteRule ^(.*)\.html $1.php [L]
and it work fine.
Now i want to rename nettoyage-detail-bureaux.php?id=21 to nettoyage-detail-bureaux-21.html
so i add
RewriteRule ^nettoyage-detail-bureaux-([0-9]+)\.html$ nettoyage-detail-bureaux.html?id=$1 [L]
it doesn't work.
Any idea ?
I think you might have a typo at the end where you have .html?id=$1 it should be .php?id=$1
So try this.
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^nettoyage-detail-bureaux-([0-9]+)\.html$ nettoyage-detail-bureaux.php?id=$1 [L]
RewriteCond %{THE_REQUEST} (.*)\.php
RewriteRule ^(.*)\.php $1.html [R=301,L]
RewriteCond %{THE_REQUEST} (.*)\.html
RewriteRule ^(.*)\.html $1.php [L]

Htaccess mod rewrite help

I want to redirect the url:
http://www.mysite.com/invite/YhMck/en
to
http://www.mysite.com/auth/accept_invite/YhMck/en
can any please help me with the RewiteRule
RewriteCond %{HTTP_HOST} ^mysite.com/invite/YhMck/en
RewriteRule (.*) http://www.mysite.com/auth/accept_invite/YhMck/en/$1 [R=301,L]
RewriteEngine On
add this to your .htaccess in your documentroot
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^/invite
RewriteRule ^invite/([^/]+)/(\w{2})$ auth/accept_invite/$1/$2
from comments:
These rules:
RewriteCond $1 !^(index\.php|robots\.txt|images|img|css|js|fonts)
RewriteRule ^(.*)$ /index.php/$1 [L]
Will add index.php to every rule that does not begin with index.php|robots\.txt|images|img|css|js|fonts
So your /invite would also have been re-written to /index.php/invite...
Try this in the same order
RewriteEngine on
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} ^/invite
RewriteRule ^invite/([^/]+)/(\w{2})$ auth/accept_invite/$1/$2 [L]
RewriteCond $1 !^(auth/|index\.php|robots\.txt|images|img|css|js|fonts)
RewriteRule ^(.*)$ /index.php/$1 [L]

What's wrong with this rewrite rule?

I have this .htaccess:
RewriteEngine On
RewriteRule ^!/(.*)$ path/to/a/file/$1 [L]
RewriteRule ^(.*)$ path/to/another/file/$1 [L]
I want urls in the form of www.website.com/!/this/ to be rewritten to path/to/a/file. Any URL that doesn't match that pattern should be rewritten to path/to/another/file/.
Here's what I've tried to far:
RewriteEngine On
RewriteRule ^!/(.*)$ path/to/a/file/$1 [L]
RewriteCond ...
RewriteRule ^(.*)$ path/to/another/file/$1 [L]
When using the above rewrite rule, I get a 500 - Internal Error.
How can I fix it?
Try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/!
RewriteRule ^!/([a-z0-9_\-\.]+) user/public/$1 [L]
RewriteCond %{REQUEST_URI} !^/!
RewriteRule ^([a-z0-9_\-\.]+)/([a-z0-9_\-\.]+)/?$ $1/controller/front.php/$2 [L]
RewriteCond %{REQUEST_URI} !^/!
RewriteRule ^([a-z0-9_\-]+)/([a-z0-9_\-]+)/([a-z0-9_\-]+)/?$ $1/controller/front.php/$2/$3 [L]

Resources