I have a problem with making friendly URL. I need to convert url from http://blabla.eu/stats_details?date=01-2012 to http://blabla.eu/stats_details/01-2012. Other Rewrite rules are working properly beside the last one. What is the problem?
Here is code of .htaccess:
AddDefaultCharset utf-8
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^admin/users/$ /admin/users/view.php [L]
RewriteRule ^admin/loans/$ /admin/loans/view.php [L]
RewriteRule ^stats_details/(.*)$ stats_details.php?date=$1 [L,QSA]
</IfModule>
I think this must to work, try to paste
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Related
I have such URL at my Magento website as http://magento.store/about and http://magento.store/index.php/about. I don't need these two pages, I need them to be properly rewrited in .htaccess file. I've tried everything which I could find at StackOverflow but nothing helps. I configured URL-rewrites in configuration using adpanel, used different solutions but the most, I got is to do these redirects but my adpanel doesn't writes any changes to the website's database (I used this solution:
RedirectMatch 301 ^/index.php/((?!admin).*) http://www.magento.store/$1
In this case it is impossible to change anything in adpanel. The usual solutions such as
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
do not also work. They are ignored as far as I understand.
How can I solve this issue?
Here is my .htaccess file (the part about the mod_rewrite):
<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]
RewriteCond %{HTTP_HOST} ^magento\.store$ [NC]
RewriteRule ^(.*)$ http://www.magento.store/$1 [L,R=301]
# redirect pagination
RewriteCond %{QUERY_STRING} ^p=1$
RewriteRule ^(.+)$ http://www.magento.store/$1? [R=301,L]
RewriteRule ^pagename$ http://www.magento.store/page-name [L,R=301]
#RewriteCond %{REQUEST_URI} !/admin/
#RewriteRule ^index\.php/(.+)$ /$1 [R,L]
#RewriteRule ^index\.php/?$ / [R,L]
#RedirectMatch 301 ^/index.php/(.*)$ /$1
#RedirectMatch 301 ^/index.php/((?!admin).*) http://magento.store/$1
RewriteRule ^api/rest api.php?type=rest [QSA,L]
############################################
## workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
############################################
## always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
Is it possible that I have some conflicts inf my file?
You can capture the part after index.php and redirect the client with
RewriteEngine on
RewriteRule ^index\.php/(.+)$ /$1 [R,L]
RewriteRule ^index\.php/?$ / [R,L]
This redirects all requests starting with index.php/ to the URL without index.php. Additionally index.php and index.php/ are redirected to the home page.
Use below .htaccess rule:
## index.php on default domain
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteCond %{REQUEST_URI} !^/downloader.*$
RewriteRule ^(.*)index.php$ http://www.idesignmydrapes.com [R=301,L]
RewriteCond %{HTTP_HOST} ^idesignmydrapes\.com$ [NC]
Thank you, everybody, for your help. Finally, I made the solution and it is the following:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !/adpanel/
RewriteRule ^index\.php/(.*)$ http://magento.store/$1 [L,R=301]
I feel this should be an easy fix but I'm struggling to get it done right.
I have the URL:
http://www.testing.com/toursgbr/my-post
http://www.testing.com/toursgbr/my-post-2
I need to rewrite the URL to:
http://www.testing.com/tours/gbr/my-post
http://www.testing.com/tours/gbr/my-post-2
I got as far as the following:
RewriteRule ^toursgbr/(.*) /tours\/gbr/$1 [L]
This is what's currently in the htaccess file:
RewriteEngine on
ErrorDocument 404 http://www.ausweb.com.au/web-hosting
AddHandler server-parsed html
# 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
RewriteCond %{HTTP_HOST} ^seabreezepark\.com\.au$ [OR]
RewriteCond %{HTTP_HOST} ^www\.seabreezepark\.com\.au$
RewriteRule ^/?$ "http\:\/\/theseabreezepark\.com\.au\/" [R=301,L]
RewriteRule ^toursgbr/(.+)$ /tours/gbr/$1 [NC,L]
and got nowhere pretty fast. I just want to look for the word "toursgbr" and change it to "tours/gbr" in summary.
Put the Following code at root .htaccess file :
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} !\s/+tours/gbr/ [NC]
# the above line will exclude any request having tours/gbr/ from the follwoing rule.
RewriteRule ^toursgbr/(.*)$ tours/gbr/$1 [R=302,L,NE]
# the above line will change any requested url having toursgbr/ to be tours/gbr/ temporary
# and you can change it to permanent by changing [R=302,L,NE] to [R=301,L,NE]
# but check the code as it is first then change it
RewriteRule ^tours/gbr/(.*)$ toursgbr/$1 [L,NC]
# the above line will internally map any request having tours/gbr/ to its original path
Try :
RewriteRule ^toursgbr/(.+)$ /tours/gbr/$1 [NC,L]
Do not use the full url in rewrite target if you want to internally redirect /toursgbr/foo to /tours/gbr/foo without changing the url in browser.
Your corrected htaccess :
ErrorDocument 404 http://www.ausweb.com.au/web-hosting
AddHandler server-parsed html
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?seabreezepark\.com\.au$
RewriteRule ^/?$ http://theseabreezepark.com.au/ [L,R=301]
RewriteRule ^toursgbr/(.+)$ /tours/gbr/$1 [NC,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
i have a site wich have a dynamic url for 3 pages only. and for that i dont go for php function. So I decided to go for .htaccess rewrite rules but I am not having any luck yet.
This is my actual url: /index.php?mode=service&inid=1
I want to rewrite it to this: /home-theater
I try it my self and with this code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mysite\.com.au$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com.au/$1 [L,R=301]
Options +FollowSymLinks
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.mysite.com.au/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^home-theater/?$ index.php?mode=service&inid=1 [L,NC,QSA]
I still can't get it to work.
Also I write index.php to www redirect before this code, so I guess if it cause any issue or not. index.php to www site redirects work perfectly but this is not working.
Use L flag like this:
RewriteRule ^home-theater/?$ index.php?mode=service&inid=1 [L,NC,QSA]
Remember this will not change the URL in the browser since this will internally forward request to your index.php.
Also if this doesn't work then provide your full .htaccess in your question.
Update: I have modified your .htaccess here, please try it out now after clearing your browser cache:
DirectoryIndex index.php
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.mysite\.com.au$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com.au/$1 [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^ http://www.mysite.com.au/ [R=301,L]
RewriteRule ^home-theater/?$ index.php?mode=service&inid=1 [L,NC,QSA]
RewriteCond %{ENV:REDIRECT_STATUS} !200
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.php [L]
I have an issue that's too complex for me to handle, but I'm betting someone has had to do this before, so please let me hear from you. ;)
Here's the situation:
I've got 1 main domain with 3 subdirectories that are nested within each other
(from top to bottom)
http://main-domain.com
then
http://main-domain.com/company-name/
then
http://main-domain.com/company-name/blog/
There's currently 3 .htaccess files -- 1 in each of the 3 directories shown above.
What's the problem?
Instead of having www.main-domain.com/company-name/blog/whatever, I'd like to have main-domain.com/blog/whatever
So, I want to drop the www AND more importantly, drop the middle subdirectory; i.e. /company-name/
I hope that the following examples will help to illustrate the point.
http://main-domain.com/company-name/index.php should be changed to http://main-domain.com/index.php
http://main-domain.com/company-name/blog/my-first-article/ should be changed to http://main-domain.com/blog/my-first-article/
Why do I need this?
I need a shorter URL that is more SEO-friendly. I have too many backlinks that use the 'old' urls, so I need to mod-rewrite them all.
Here are My Current 3 htaccess files
root htaccess: main-domain.com
#Bypass InoCore Templating System
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /reservations/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /reservations/default.php [L]
Options -Indexes
</IfModule>
#END Bypass
#301 REDIRECT
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^info.php - [L]
RewriteCond %{HTTP_HOST} ^www.domain1.com [NC]
RewriteRule ^(.*)$ http://www.main-domain.com/company-name/$1 [R=301,NC]
RewriteCond %{HTTP_HOST} ^domain1.com [NC]
RewriteRule ^(.*)$ http://www.main-domain.com/company-name/$1 [R=301,NC]
RewriteCond %{HTTP_HOST} ^www.domain2.com [NC]
RewriteRule ^(.*)$ http://www.main-domain.com/company-name/$1 [R=301,NC]
RewriteCond %{HTTP_HOST} ^domain2.com [NC]
RewriteRule ^(.*)$ http://www.main-domain.com/company-name/$1 [R=301,NC]
RewriteCond %{HTTP_HOST} ^www.domain3.com [NC]
RewriteRule ^(.*)$ http://www.main-domain.com/company-name/$1 [R=301,NC]
RewriteCond %{HTTP_HOST} ^domain3.com [NC]
RewriteRule ^(.*)$ http://www.main-domain.com/company-name/$1 [R=301,NC]
RewriteCond %{HTTP_HOST} ^main-domain.com [NC]
RewriteRule ^(.*)$ http://www.main-domain.com/company-name/$1 [R=301,NC]
RewriteCond %{HTTP_HOST} ^www.main-domain.com [NC]
RewriteRule ^(.*)$ http://www.main-domain.com/company-name/$1 [R=301,NC]
company-name htaccess: main-domain.com/company-name/
RewriteEngine on
RewriteRule ^maping.php /maping.php
RewriteRule ^$ index.php?$1 [L]
RewriteRule (.*) index.php?$1 [L]
#php_flag magic_quotes_gpc off
#BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /company-name/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /company-name/index.php [L]
</IfModule>
#END WordPress
blog htaccess: main-domain.com/company-name/blog/
RewriteEngine off
#BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /company-name/blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /company-name/blog/index.php [L]
</IfModule>
#END WordPress
Your correct and compact root .htaccess should be like this:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^info.php - [L]
# match all the domains in single condition while www. is optional
RewriteCond %{HTTP_HOST} ^(www\.)?(domain1|domain2|domain3|main-domain)\.(com|tld)$ [NC]
RewriteRule ^company-name/(.*)$ http://www.domain.tld/$1 [R=301,L,NC,NE]
R=301 will redirect with https status 301
L will make last rule
NE is for no escaping query string
NC is for ignore case comparison
$1 is your REQUEST_URI matching group
I have pagination plugin in my CMS which produces ?pg=1 links. I want to redirect this url without this ugly postfix because without it CMS shows first page too.
So, i have url like http://site.ru/category/schock-crane/?pg=1 or http://site.ru/moyka/?type=granit&pg=1
I want to redirect such urls to http://site.ru/category/schock-crane/ and http://site.ru/moyka/?type=granit respectly.
I tried this .htaccess code
RewriteRule (.*)(&|\?)pg=1$ $1 [R=301,L]
I tried this regexp code at regexp trainers - it worked. But at live server no redirect happens.
Here is whole .htaccess file:
AddDefaultCharset Off
#DirectoryIndex index.php index.html
Options +FollowSymLinks
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# fix /?pg=1
RewriteRule (.*)(&|\?)pg=1$ $1 [R=301,L]
# fix .palitra-tab
RewriteCond %{REQUEST_URI} -tab$
RewriteRule (.*)/([0-9]*)/\.(.*)-tab?$ http://site.ru/redirect.php?id=$2 [R=301,L]
RewriteCond %{REQUEST_URI} ^/csss/.* [NC]
RewriteRule csss/(.*)\.css$ css.php?n=$1 [L]
#RewriteRule ^(.*)/csss/(.*) /test.php [L]
RewriteRule ^(.*)/base([0-9]+)/?$ $1?base=$2
#RewriteCond %{REQUEST_FILENAME} -f
#RewriteRule \.(gif|jpeg|jpg|png)$ /images/watermark/index.php [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php
RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
You need to use RewriteCond to examine the query string:
RewriteCond %{QUERY_STRING} ^(([^&]*&)*)pg=1(&(.*)|$)
RewriteCond %1%4 (.*?)&?$
RewriteRule ^ %{REQUEST_URI}?%1 [R=301,L]
The second RewriteCond is just to remove a trailing &.
Maybe the missing ^ or / kills the redirect
# fix /?pg=1
RewriteRule ^(.*)(&|\?)pg=1$ /$1 [R=301,L]
or try
RewriteRule ^(.*)(&|\?)pg=1$ http://%{HTTP_HOST}/$1 [R=301,L]