this my website mapping
--domain.com
------mainpage
---------index.php
my domain.com inside have a mainpage folder and inside the the folder have a index.php.
the url now
http://domain.com/mainpage/
the url i wanted(removing the slash)
http://domain.com/mainpage
.htaccess
Options +FollowSymLinks
RewriteEngine On
DirectorySlash Off
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !directory/(.*)$
RewriteCond %{REQUEST_URI} !(.*)$
RewriteRule ^(.*)$ http://domain.com/mainpage/$1 [R=301,L]
Try this:
RewriteEngine On
RewriteRule ^mainpage$ /mainpage/index.php [L]
Related
My folder structure is, I used htaccess for NO trailing slash at the end of each URL
-job.php to /job
-companies.php to /companies
-about.php to /about
-Admin_jobs(This is Admin Folder)
and My .htaccess file is
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{HTTP_HOST} ^sitename.com [NC]
#redirect to www
RewriteRule ^(.*)$ http://www.sitename.com/$1 [L,R=301]
.
I am trying to access my Admin_jobs/ folder then it was redirecting to my main site, www.example.com. I cannot access to My admin pages. Anybody is there to help me.
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]
im wondering how Rewrite path like this www.domain.com/pages/article/
to www.domain.com
i did it but CSS files has changed path too
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} ^index.php$
RewriteRule . http://www.domain.com/ [L]
Add exclusions for those in separate rewrite conditions.
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(css|js|png|jpe?g|gif)$ [NC]
RewriteCond %{REQUEST_FILENAME} ^index.php$
RewriteRule . http://www.domain.com/ [L]
I would like all URLs except my root URL (/ and /index.php) and the JS/CSS and image assets it uses, to redirect to another URL. All assets are contained in the /assets directory
Here's what I have so far but it's not working
RewriteEngine on
RewriteRule ^(.*)\.(?!js|css)([^.]*)$ $1\.php
RewriteCond %{REQUEST_URI} !^.assets$
RewriteCond %{REQUEST_URI} !/index.php$
RewriteCond %{REQUEST_URI} !/style.php$
RewriteCond %{REQUEST_URI} !/$
RewriteRule $ http://berlincallingny.eventbrite.com [R=302,L]
The rules I need are:
do not rewrite any URL containing "assets"
Do not rewrite index.php
Do not rewrite style.php
Do not rewrite the root URL
do not rewrite any URL containing .css or .js
Thank you!
Your regex for assets directory is not correct here:
RewriteCond %{REQUEST_URI} !^.assets$
Replace your code with this:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/assets(/.*|)$ [NC]
RewriteCond %{REQUEST_URI} !/(index|style)\.php$ [NC]
RewriteRule ^.+$ / [R=302,L]
I've upgraded an old website and wanted to redirect all the old pages to the new ones. the old website used the index page and a query string to server the relevant content.
here is the new htaccess file. the problem in question is getting the redirect to work. also if you can steamline this file:
Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.domain.co.uk$ [NC]
RewriteRule ^(.*)$ http://domain.co.uk/$1 [R=301,L]
#if its not a directory
RewriteCond %{REQUEST_FILENAME} !-d
#and it has a trailing slash then redirect to URL without slash
RewriteRule ^(.+)/$ /$1 [L,R=301]
#this removes php extention
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
# stops you accessing url with.php
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^.?\ ]+)\.php
RewriteRule ^([^.]+)\.php(/.+)?$ /$1%{PATH_INFO} [R=301]
RewriteRule ^news/([^/]*)/([^/]*)$ /news?id=$1&title=$2 [L]
Redirect 301 index?page=about http://domain.co.uk/about
ErrorDocument 404 http://domain.co.uk/404
The apropiate rule to redirect domain.com/index.php?page=about to domain.com/about is the following
RewriteRule ^index\.php$ %{QUERY_STRING} [C]
RewriteRule page=(.*) /$1? [R=301,L]