.htaccess

Modern favicons & htaccess rewrite rule

限于喜欢 提交于 2020-01-20 08:52:45
问题 Instead of having all the new favicon formats placed into the root directory of my website, I am placing them inside a subfolder. To conform to the standards, as some browsers / device versions do not use the path as directed inside the html meta tags, but instead try to get the file from the website root anyway, I am creating a rewrite rule to redirect all these files to the actual location - but ONLY these files. What I have come up with so far is the following : RewriteEngine On

.htaccess rewrite to convert directories into /key/value/key/value

僤鯓⒐⒋嵵緔 提交于 2020-01-20 06:53:35
问题 I've seen it before where a rule was used to convert directories on a URL to key=value request queries. I have no idea how to do this so I can have more than one of these pairs. For example: http://www.example.com/mykey/myvalue/mykey2/myvalue2 Would map to: http://www.example.com?mykey=myvalue&mykey2=myvalue2 Thanks. 回答1: Use this .htaccess code to have recursion based translation of key/value based URI: Options +FollowSymLinks -MultiViews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d

.htaccess rewrite to convert directories into /key/value/key/value

末鹿安然 提交于 2020-01-20 06:51:05
问题 I've seen it before where a rule was used to convert directories on a URL to key=value request queries. I have no idea how to do this so I can have more than one of these pairs. For example: http://www.example.com/mykey/myvalue/mykey2/myvalue2 Would map to: http://www.example.com?mykey=myvalue&mykey2=myvalue2 Thanks. 回答1: Use this .htaccess code to have recursion based translation of key/value based URI: Options +FollowSymLinks -MultiViews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d

Mod rewrite using .htaccess

只愿长相守 提交于 2020-01-20 06:41:29
问题 I am trying to Rewrite my mode using this info[copy from a website], but it's not working .. what's wrong with it and plz give a correct answer.. The Apache rewrite engine is mainly used to turn dynamic url’s such as www.yoursite.com/product.php?id=123 into static and user friendly url’s such as www.yoursite.com/product/123 RewriteEngine on RewriteRule ^product/([^/.]+)/?$ product.php?id=$1 [L] Another example, rewrite from: www.yoursite.com/script.php?product=123 to www.yoursite.com/cat

Removing GET parameter in .htaccess

懵懂的女人 提交于 2020-01-19 17:35:39
问题 I'm not able to remove one GET parameter wrongly added by one 404 SEF module. I want to remove "task=view" only if it appears alone and not with another parameter. So www.mysite.com/1.html?task=view should be redirected to www.mysite.com/1.html . While www.mysite.com?task=view&view=article should remain unchanged. No matter which RewriteRule I use, this paramater does not go. Looks like it is being generated from any environment variable when index.php is run. For example this does not work:

Removing GET parameter in .htaccess

爱⌒轻易说出口 提交于 2020-01-19 17:35:32
问题 I'm not able to remove one GET parameter wrongly added by one 404 SEF module. I want to remove "task=view" only if it appears alone and not with another parameter. So www.mysite.com/1.html?task=view should be redirected to www.mysite.com/1.html . While www.mysite.com?task=view&view=article should remain unchanged. No matter which RewriteRule I use, this paramater does not go. Looks like it is being generated from any environment variable when index.php is run. For example this does not work:

Add Trailing Slash to URLs

五迷三道 提交于 2020-01-19 03:48:07
问题 There are quite a few results for add trailing slash .htaccess on Google, but all examples I found require the use of your domain name, as in this example: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !example.php RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301] My problem is that a hard-coded domain name will not work on my local development machine. Is there a way to add trailing slashes without explicitly

Rewrite .htaccess for https

倾然丶 夕夏残阳落幕 提交于 2020-01-17 18:18:05
问题 I have an .htaccess file on my http site. Our system administrator made https settings and I can get my site by https. But the problem is that I can't rewrite .htaccess file. For example: RewriteEngine On Options -MultiViews RewriteRule ^(index|getReadings|admin|adminNewDesign)\/([A-Za-z]*)$ $1.php?id=$2 [L,QSA,NC] This works fine on http, but doesn't work on https. I tried like this: RewriteEngine On Options -MultiViews RewriteCond %{HTTPS} On RewriteRule ^(index|getReadings|admin

PHP: GET Variables on Mod Rewritten URL

雨燕双飞 提交于 2020-01-17 17:29:39
问题 I'm trying to pass parameters and use the GET function in PHP on a URL that has already been rewritten using mod rewrite. I have this in my HTACCESS file: Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^-]*)/$ ?action=$1 [L] RewriteRule ^search/$ ?action=search [L] If I have a URL like http://www.example.com

PHP: GET Variables on Mod Rewritten URL

假装没事ソ 提交于 2020-01-17 17:29:20
问题 I'm trying to pass parameters and use the GET function in PHP on a URL that has already been rewritten using mod rewrite. I have this in my HTACCESS file: Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^-]*)/$ ?action=$1 [L] RewriteRule ^search/$ ?action=search [L] If I have a URL like http://www.example.com