I got some problem with my htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^contact/ index.php?p=contact [L]
RewriteRule ^imprint/ index.php?p=imprint [L]
RewriteRule ^escort-rates/ index.php?p=escort-rates [L]
RewriteRule ^discretion-reliability/ index.php?p=discretion-reliability [L]
RewriteRule ^(escort-model)/(\.*)/$ index.php?p=$1&l=$2 [L]
If I call www.domain.com/contact/ the URL won't change visible, but is internally directed to index.php?p=contact, it works with the other 3 ones also.
But if I call www.domain.com/escort-model/escortname/ the URL changes visible to the visitor.
The correct page is called, but the URL changes to index.php?p=escort-model&l=escortname
Any hint would be greatly appreciated.
I think it should be (without the parenthesis):
RewriteRule ^escort-model/(.*)/$ index.php?p=$1&l=$2 [L]
instead of:
RewriteRule ^(escort-model)/(.*)/$ index.php?p=$1&l=$2 [L]
Related
My old url
www.example.com/cn/news
www.example.com/cn/event
I want to if user enter /cn url Laravel will redirect into this url
www.example.com/en/news
www.example.com/en/event
here is my laravel .htaccess in root folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
I try this one but it doest work
RewriteCond %{THE_REQUEST} /cn [NC]
RewriteRule ^ /%1/en/%2/? [L,R=301]
UPDATE
now .htaccess look like this but still didnt work
RewriteEngine On
RewriteRule ^(.)$ public/$1 [L]
RewriteRule ^cn/(.)$ en/$1 [L,R=301]
RewriteRule ^cn/?(.*)$ en/$1 [L,R=301]
This rule alone should work.
Match a cn prefix with an optional / and capture all characters after the /.
What I'm looking to do is rewrite the url so that one of the directories are hidden. For example;
http://www.example.com/home/example.html
to
http://www.example.com/example.html
As I'm new to .htaccess and mod_rewrite, is this something that can be done?
This should work:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/home/.*$
RewriteRule ^(.*)$ /home/$1 [L]
Something like this should work.
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^example.html$ /home/example.html [NC,L]
I have been using mod re-write ok up until now.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/?(shopping-catalogue)/([0-9]+) index.php?friendly_url=$1&view=catalogue&catalogue_id=$2 [L]
RewriteRule ^/?(shopping-catalogue)/(category)/([0-9]+) index.php?friendly_url=$1&view=$2&category_id=$3 [L]
RewriteRule ^/?(shopping-catalogue)/(category-item)/([0-9]+) index.php?friendly_url=$1&view=$2&category_item_id=$3 [L]
RewriteRule ^/?(shopping-catalogue)/(category-item-option)/([0-9]+) index.php?friendly_url=$1&view=$2&category_item_option_id=$3 [L]
# marketing module see newsletter before sending
RewriteRule ^/?(newsletters)/([A-Za-z0-9-]+)/(newsletter)\.html /newsletters/$2/newsletter.html [L]
RewriteRule .([^/]+)\.html index.php [L]
#RewriteRule ^/client-area/CLID/([0-9]+) /index.php?temp=template_dataroom&CLID=$1 [L]
# allow access with no restrictions to local machine at 192.168.1.3
RewriteCond %{REMOTE_ADDR} !192.168.1.3
# allow access to all .css and .js in sub-directories..
RewriteCond %{REQUEST_URI} !\.css$
RewriteCond %{REQUEST_URI} !\.js$
# allow access to the files inside img/, but not a directory listing..
RewriteCond %{REQUEST_URI} !dataroom/(.*)\.
RewriteRule ^files/([^/]+)/([^/]+).zip /download.php?section=$1&file=$2 [NC]
# allow access to these particular files...
My problem seems to be that this line gets ignored
# marketing module see newsletter before sending
RewriteRule ^/?(newsletters)/([A-Za-z0-9-]+)/(newsletter)\.html /newsletters/$2/newsletter.html [L]
I am trying to access an html file directly but the folder is a unique name each time.... ie -
http://www.awebsite.co.uk/newsletters/template_4fd09c5b429ea/newsletter.html
This line is being ignored. I do not understand why?
Any help would be much appreciated.
Thanks
Andi
ok I got it working now,. Took the / off the redirected link
Here is the line I now have
# marketing module see newsletter before sending
RewriteRule ^/?(newsletters)/([A-Za-z0-9_]+)/(newsletter)\.html newsletters/$2/newsletter.html [L]
Thanks
Andi
I haven't checked the result but you do not seem to be allowing the underscore
RewriteRule ^/?(newsletters)/([A-Za-z0-9-]+)/(newsletter)\.html /newsletters/$2/newsletter.html [L]
RewriteRule (newsletters)/([A-Za-z0-9|-|_]+)/(newsletter)\.html /newsletters/$2/newsletter.html [L]
Also, I don't think you need to starts with bit (^).
I have a search form and when I make a search I get this URL "http://****/video/view/search/?imeto_tam=tarsene" but I want to replace this the "?imeto_tam=tarsene" with the word I search for and my address to look like this - "http://****/video/view/search/tarsene". Generally I use mod_rewrite on my site and it's working for my links but it's not working for the form-s. Could someone tell me how to do it?
RewriteEngine On
RewriteRule ^view/([0-9a-zA-Z\-\(\)]+)/?$ index.php?a=$1 [L]
RewriteRule ^view/([0-9a-zA-Z\-():]+)/([0-9a-zA-Z\-():\.,]+)$ index.php?a=$1&id=$2 [L]
These rules would go into your root .htaccess file and 301 redirect the querystring imeto_tam to the folder and then the next rule would make it get passed to your code (index.php)
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?imeto_tam=([^&]+)(&.*)?$ [NC]
RewriteRule ^video/view/search/(index\.php)?$ /video/view/search/%2/? [R=301,L]
RewriteRule ^video/view/search/([^/]+)/$ /video/view/search/index\.php?imeto_tam=$1 [L]
I have a problem with mod-rewrite, to be more precise, it doesn't redirect me properly. Everything works fine on my local server, the problem only occurs when the site goes live... This is what I have in the .htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^(tutorial|news|out|profile|script)/([0-9]+)/?$ $1.php?id=$2 [L]
RewriteRule ^(tutorial|news)/([0-9]+)/post-comment/?$ $1.php?id=$2&action=postcmt [L]
RewriteRule ^atelier/([0-9]+)/?$ img/gallery/view.php?id=$1 [L]
RewriteRule ^([a-zA-Z0-9]+)/page/([0-9]+)/?$ $1.php?page=$2 [L]
RewriteRule ^get/([a-zA-Z0-9]+)/([0-9]+)/?$ $1/get.php?id=$2 [L]
RewriteRule ^get/brushes/(abr|img)/([0-9]+)/?$ brushes/$1.php?id=$2 [L]
RewriteRule ^([a-zA-Z0-9]+)/(c|series|type)/([0-9]+)/page/([0-9]+)/?$ $1.php?$2=$3&page=$4 [L]
RewriteRule ^([a-zA-Z0-9]+)/(c|series|type)/([0-9]+)/?$ $1.php?$2=$3 [L]
RewriteRule ^design/preview/([0-9]+)/?$ design/preview.php?id=$1 [L]
RewriteRule ^([a-zA-Z0-9]+)/send/?$ $1.php?action=send [L]
RewriteRule ^askme/post-question/?$ ask.php?action=ask [L]
If I enter news/5/ for example, it will only redirect me to news.php, design/preview/5 will only take me to design/preview.php and so forth. On the contrary, get/brushes/abr/1 works fine... I have no idea what I'm doing wrong, any suggestions?
MultiViews could cause this behavior. Try to disable it:
Options -MultiViews
Just to start from the simplest place and add complication after, does this work for you?
RewriteRule ^news/([^/\.]+)/?$ news.php?id=$1 [L,NC]