mod-rewrite

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

PHP & Hash / Fragment Portion of URL

牧云@^-^@ 提交于 2020-01-19 03:28:26
问题 I am trying to find a way to save the hash portion of a url and as a PHP variable. This idea is a bit kooky, but bear with me... I'd like to extract the "location" fragment from the following URL and save it as a PHP variable. http://www.example.com/#location However, discussion at this link indicates that the fragment of a URL is only reachable through JavaScript. But would it be possible to create a link where the fragment is duplicated in the URL, parsed by PHP, and then removed by mod

PHP & Hash / Fragment Portion of URL

半世苍凉 提交于 2020-01-19 03:28:13
问题 I am trying to find a way to save the hash portion of a url and as a PHP variable. This idea is a bit kooky, but bear with me... I'd like to extract the "location" fragment from the following URL and save it as a PHP variable. http://www.example.com/#location However, discussion at this link indicates that the fragment of a URL is only reachable through JavaScript. But would it be possible to create a link where the fragment is duplicated in the URL, parsed by PHP, and then removed by mod

Redirect to Apache built-in 404 page with mod_rewrite?

北城以北 提交于 2020-01-18 16:20:43
问题 Is there a way to actively serve Apache's default, built-in 404 page for a number of URLs using mod_rewrite? Not a custom error document, but a rule like RewriteCond %{REQUEST_URI} ^/dirname/pagename RewriteRule -- serve 404 page ----- I know how to build a PHP page that sends the 404 header and have mod_rewrite redirect all the URLs there but I would prefer a solution that is based on mod_rewrite only. I just had the idea of redirecting to a non-existent address: RewriteCond %{REQUEST_URI} ^

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

htaccess http to https with www. Without redirecting sub domain

爱⌒轻易说出口 提交于 2020-01-17 11:09:36
问题 I have a RewriteRule that redirects my main domain to https://www.sta-games.com which works fine, but when I try to access my subdomain http://files.sta-games.com , it redirects to my main domain. Heres my redirect rules #HTTPS Redirection RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Can anyone see the problem? 回答1: You need to adjust your rules so

htaccess http to https with www. Without redirecting sub domain

末鹿安然 提交于 2020-01-17 11:07:27
问题 I have a RewriteRule that redirects my main domain to https://www.sta-games.com which works fine, but when I try to access my subdomain http://files.sta-games.com , it redirects to my main domain. Heres my redirect rules #HTTPS Redirection RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Can anyone see the problem? 回答1: You need to adjust your rules so