What am I doing wrong here? It does not work for me :(
Options +FollowSymLinks -MultiViews
RewriteEngine on
# use appropriate rewrite base
RewriteBase /stage/customer/be/
RewriteCond %{REQUEST_METHOD} !^(TRACE|TRACK|GET|POST|HEAD)$
RewriteRule ^ - [F]
RewriteCond %{THE_REQUEST} /index\.php\?action=([\w-]+)&template_id=([\w-]+)&feedbackTypeID=([\w-]+) [NC]
RewriteRule ^ %1/%2/%3? [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/?$ index.php?action=$1&template_id=$2&feedbackTypeID=$3 [L,QSA]
This is a continutation of this thread again a new .htaccess issue
I have this code in the htaccess one folder above from where the call is being made. Not sure if this would affect the "be" folder as well.
Options +FollowSymLinks -MultiViews
RewriteEngine on
# use appropriate rewrite base
RewriteBase /stage/customer/
RewriteCond %{REQUEST_METHOD} !^(TRACE|TRACK|GET|POST|HEAD)$
RewriteRule ^ - [F]
RewriteCond %{THE_REQUEST} /index\.php\?id=([\w-]+)\s [NC]
RewriteRule ^ %1? [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ index.php?id=$1 [L,QSA]
Related
I would like to rewrite http://example.com/test/index.php?id=123
to http://example.com/test/item/123/ and http://example.com/test/index.php?id=123 redirect to the human friendly url.
I don't know what is wrong in my htaccess :
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /test/
RewriteCond %{QUERY_STRING} ^id=([a-z0-9]+)$ [NC]
RewriteRule ^/item/%1/? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^item/([a-z0-9]+)/$ index.php?id=$1 [L]
You can use the following RewriteRule in your /test/.htaccess file
Options +FollowSymLinks -MultiViews
RewriteEngine on
#redirect old url to the new one
RewriteCond %{THE_REQUEST} /test/index\.php\?id=([^\s]+) [NC]
RewriteRule ^ /test/item/%1? [L,R=301]
#internally map new url to the old one
RewriteRule ^item/(.+)/?$ /test/index.php?id=$1 [L,NC]
I have a website which consists only from .html frontend and I want to have pretty URLs. My goal is to create something like this
http://test.com/mypage.html => http://test.com/mypage
http://test.com/mypage1.html => http://test.com/mypage1
and for one specific page
http://test.com/my-prettlink.html?id=1 => http://test.com/my-prettlink/1
I tried this .htaccess which is located in project root but only removing .html works.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^my-prettylink/(\d+)*$ ./my-prettylink.html?id=$1
More specific rules should come before general rules. So, try:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /subdirectory/
RewriteCond %{THE_REQUEST} ^GET\ /(subdirectory/my-prettylink)\.html\?id=(\d+) [NC]
RewriteRule ^my-prettylink\.html$ /%1/%2? [R=301,L]
RewriteCond %{THE_REQUEST} ^GET\ /(subdirectory/.+)\.html [NC]
RewriteRule ^ /%1? [R=301,L]
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^my-prettylink/(\d+)$ my-prettylink.html?id=$1 [L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(?!js|css) %{REQUEST_URI}.html [L]
and also add <base href='/subdirectory/' /> in header
Here are my rewrite script (.htaccess)
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(action|ajax|api|uploads)(.*)$ - [L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./index.php
Now I have the url: http://domain.tld/uploads/users/1/pictures/1443563069.jpg
The picture exist, but i can't load it. Is something with my rewrite rule not ok?
Try this code in root .htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} /(action|ajax|api|uploads) [NC]
RewriteRule ^ - [L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^ index.php [L]
Using %{THE_REQUEST} because REQUEST_URI changes to /index.php in your last rule.
One of my URL has this /index.php?page=cfeedback&status_id=2&cf_store=8 ... After applying this htaccess it shows only /index.php?page=cfeedback in the URL.
Anything can be done for this?
Some pages also are just /index.php?page=dashboard.
My .htaccess should support both in this fashion.
/dashboard for URLs /index.php?page=dashboard
/cfeedback/2/8 for URLs /index.php?page=cfeedback&status_id=2&cf_store=8
This is a continuation of this issue: .htaccess file is not working on server
My .htaccess code is
Options +FollowSymLinks -MultiViews
RewriteEngine on
# use appropriate rewrite base
RewriteBase /mydir/admin/
RewriteCond %{REQUEST_METHOD} !^(TRACE|TRACK|GET|POST|HEAD)$
RewriteRule ^ - [F]
RewriteCond %{THE_REQUEST} /index\.php\?page=([\w-]+) [NC]
RewriteRule ^ %1? [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ index.php?page=$1 [L,QSA]
I tried adding the following code for urls having index.php?page=$1&status_id=$2 . Please let me know what I am doing wrong.
RewriteCond %{THE_REQUEST} /index\.php\?page=([\w-]+)&status_id=([\w-]+) [NC]
RewriteRule ^ %1/%2? [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/([\w-]+)/?$ index.php?page=$1&status_id=$2 [L,QSA]
What am I doing wrong here?
Options +FollowSymLinks -MultiViews
RewriteEngine on
# use appropriate rewrite base
RewriteBase /mydir/admin/
RewriteCond %{REQUEST_METHOD} !^(TRACE|TRACK|GET|POST|HEAD)$
RewriteRule ^ - [F]
RewriteCond %{THE_REQUEST} /index\.php\?page=([\w-]+)&status_id=([\w-]+)&cf_store=([\w-]+) [NC]
RewriteRule ^ %1/%2/%3? [L,R]
RewriteCond %{THE_REQUEST} /index\.php\?page=([\w-]+)&status_id=([\w-]+) [NC]
RewriteRule ^ %1/%2? [L,R]
RewriteCond %{THE_REQUEST} /index\.php\?page=([\w-]+)\s [NC]
RewriteRule ^ %1? [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/?$ index.php?page=$1&status_id=$2&cf_store=$3 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/([\w-]+)/?$ index.php?page=$1&status_id=$2 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ index.php?page=$1 [L,QSA]
Insert new set of rules before earlier rules:
Options +FollowSymLinks -MultiViews
RewriteEngine on
# use appropriate rewrite base
RewriteBase /mydir/admin/
RewriteCond %{REQUEST_METHOD} (TRACE|TRACK|GET|POST|HEAD)
RewriteRule ^ - [L]
RewriteCond %{THE_REQUEST} /index\.php\?page=([\w-]+)&status_id=([\w-]+)&cf_store=([\w-]+) [NC]
RewriteRule ^ %1/%2/%3? [L,R]
RewriteCond %{THE_REQUEST} /index\.php\?page=([\w-]+)\s [NC]
RewriteRule ^ %1? [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/?$ index.php?page=$1&status_id=$2&cf_store=$3 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ index.php?page=$1 [L,QSA]
Is it possible to create a pretty url without having to touch the file itself? For example:
http://sawebdev01/company/news-events/press-releases/press-release/?pr=168#.Uajh_kCyBSK
And convert it to:
http://sawebdev01/company/news-events/press-releases/pr/168
I tried this, and it does not seem to work:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} /company/news-events/press-releases/press-release/?pr=([^&]+) [NC]
RewriteRule .* /company/news-events/press-releases/press-release/pr/%1? [R=301,L]
Try this code:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s(/company/news-events/press-releases)/press-release/\?pr=([^&]+) [NC]
RewriteRule ^ %1/pr/%1? [R=302,L]
RewriteRule ^(company/news-events/press-releases)/pr/([^/]+)/?$ /$1/press-release?pr=$2 [L,NC,QSA]