mod-rewrite

mod_rewrite redirect all to https except one file

瘦欲@ 提交于 2020-01-05 04:29:08
问题 i use this code RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} to redirect all request to HTTPS and that is ok. Now I want same thing except one file index810.php when i write like this RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} !^ index810.php RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} i get too many redirects, any suggestions. Thank you in advance 回答1: A solution is to use a non rewriting rule: # do nothing for /index810.php RewriteRule

mod_rewrite - redirect to root and replace underscores with dashes

走远了吗. 提交于 2020-01-05 04:11:14
问题 I have been agonising over this for a few hours - trying to get to grips with the syntax for mnod_rewrite, Basically, I am migrating a site so that urls like: http://www.somedomain.co.uk/news/article/a_blog_post becomes http://www.somedomain.co.uk/a-blog-post The two key things here are removing the "/news/article" bit and replacing underscores with dashes. RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/?news/article$ RewriteRule ^([^_]*)_([^_]*_.*)$ $1-$2 [N] RewriteCond %

Htaccess breaks css and javascripts

旧街凉风 提交于 2020-01-05 03:54:06
问题 RewriteRule ^([^/]*)/([^/]*)$ index.php?sayfa=$1&id=$2 [L] i have an htaccess code like this but it breaks css, javascripts and images. something happens like this sayfa = css id = style.css 回答1: I would suggest just checking if the file exists using a rewrite condition: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)/([^/]*)$ index.php?sayfa=$1&id=$2 [L] This essentially says, if the requested filename does not actually exist on disk and is not a

What is the meaning of ^ and $ in Apache HTTPD RewriteRule?

你离开我真会死。 提交于 2020-01-05 03:53:05
问题 I have successfully added the following code to my Apache HTTPD configuration: # Force www. RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L] # Force https (SSL) RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] Although it works as expected, I have a theoretical question: Why are there a ^ and $ in 3rd line enforcing "www.", and not in the 6th line enforcing "https"? Sincerely, Dovid. 回答1: For both of your regex

Change domain depending on url path

帅比萌擦擦* 提交于 2020-01-05 03:48:06
问题 I've got a multilingual website that works within different domains deppending on the language. All the domains share the same font code and the website (Drupal) determines the language using the path. Right now I've configured each domain to be redirected to its own language, so I've got: www.example.com -> www.example.com/en www.example.es -> www.example.es/es www.example.ru -> www.example.ru/ru This way, when an user enters the website the cms will switch the language to the one

Directory rewrite in .htaccess to another directory

自闭症网瘾萝莉.ら 提交于 2020-01-05 03:46:37
问题 I have .htaccess that does this: https://example.com/john shows the contents of the directory https://example.com/user/index.php?username=john RewriteRule ^([a-zA-Z0-9_-]+)$ /user/index.php?username=$1 [QSA] How can I make it so https://example.com/john/blah will show the contents of https://example.com/user/blah ? Only show contents of /user folder if my previous rewrite rule was applied. For example: example.com/john/haha ---> example.com/user/haha example.com/privacy/blah ---> // Will show

htaccess->show file if in cache directory, if not continue

别来无恙 提交于 2020-01-05 03:33:52
问题 Im playing arround with cache. What I want is the following logic: if ( file_exist(/cache/$request_uri.txt) ){ 1. show that file 2. Stop all rewrite actions, but perform other actions (like charset, error_pages) } else{ do whatever you normally do } Small example. I have the following files http://domain.com/example-123.htm (the requested page) http://domain.com/cache/example-123.htm.txt (the cache-version of that page) http://domain.com/someDir/example-456.htm (the requested page) http:/

htaccess->show file if in cache directory, if not continue

你离开我真会死。 提交于 2020-01-05 03:33:13
问题 Im playing arround with cache. What I want is the following logic: if ( file_exist(/cache/$request_uri.txt) ){ 1. show that file 2. Stop all rewrite actions, but perform other actions (like charset, error_pages) } else{ do whatever you normally do } Small example. I have the following files http://domain.com/example-123.htm (the requested page) http://domain.com/cache/example-123.htm.txt (the cache-version of that page) http://domain.com/someDir/example-456.htm (the requested page) http:/

url rewrite not working .htaccess

痴心易碎 提交于 2020-01-05 02:50:08
问题 I am trying to rewrite the url using htaccess and I have tried answers given on another questions here however nothing seems to be working at all I still get the original url. this is what I have: http://localhost/inbox.php?pg=2 I want http://localhost/inbox/2 I already had a rule that gets rid of the .php extension in .htaccess as below and just added the last line Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST

.htaccess: Rewrite rule issue, how to redirect all to admin panel

ⅰ亾dé卋堺 提交于 2020-01-05 00:50:07
问题 I want to redirect my website to admin panel Like localhost/website/ => localhost/website/admin localhost/website/login => localhost/website/admin localhost/website/blog => localhost/website/admin Here is my created rule RewriteEngine on RewriteCond $1 !^(index\.php) RewriteRule ^(.*)$ /website/admin/$1 [L] But this is not working 回答1: The following code will redirect everything to your admin page, keeping the attributes. This also applies to files who already exist ! RewriteEngine On