mod-rewrite

.htaccess redirect https url to http

江枫思渺然 提交于 2019-12-12 02:00:03
问题 I have a website with some areas that use https, however I'm having problems changing a few https urls to http ones. This is what I need: change this url url https://www.domain.com/somefile.php?PossibleGetParameters to this: http://www.domain.com/somefile.php?PossibleGetParameters This is what I have on my .htaccess: RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI} !^(/somefile.php) RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] With this condition all https urls are turned

Apache mod_rewrite is removing slashes and generally ignoring my rules

时光总嘲笑我的痴心妄想 提交于 2019-12-12 01:59:34
问题 I'm at my wit's end, Stack Overflowers. Trying to do what I thought was a simple rewrite rule to replace slashes in the URL with tilde, then add a ".html" at the end. So my .htaccess is thus: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/(.+)/(.+)$ $1~$2 [N] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/([^/]+)$ $1.html [L] Basically I'm running a repeated rule to replace all slashes with tildes

mod_rewrite error: [client 127.0.0.1] File does not exist

≡放荡痞女 提交于 2019-12-12 01:57:37
问题 I want to start using mod_rewrite so i can use friendly url's in the future. Im testing all in my localhost dev. environment but, Im not having any luck getting the module to work! My modules is enabled (apache restarted): LoadModule rewrite_module modules/mod_rewrite.so The file named mod_rewrite.so exists under the modules folder in my Apache installation directory I've created a file named .htaccess under c:/public_html/ For testing purposes, ive created my first rules like so:

.htaccess, mod_rewrite, regex with directory and filetype

馋奶兔 提交于 2019-12-12 01:57:13
问题 I want to do a rewrite with the following conditions: Directory is /images file has a .jpg, .png or .gif extension I want to redirect to the following /images/?file=filename.extension This is not working: RewriteRule /images/(.*\.jpg|png|gif) /images/?file=$1 Example: /images/example.jpg => /images/?file=example.jpg Thanks 回答1: I think you need parens to group the extensions. /images/(.*\.(jpg|png|gif)) 回答2: In the .htaccess file, the path is stripped of the leading slash so you need to start

mod_rewrite redirect root uri to index.php

那年仲夏 提交于 2019-12-12 01:56:47
问题 I have a .htaccess file RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [QSA] It works fine if i enter url www.domain.com/something and also css and js files ar loaded. The problem begins if i enter just www.domain.com (without any params) - browser displays blank. What i need to add so that www.domain.com opens index.php and still all the css files will load? I tried this RewriteRule . /index.php [QSA,L] but it then

Redirect any page passing certain variables

给你一囗甜甜゛ 提交于 2019-12-12 01:54:52
问题 I'm putting a search engine on my site, and the search box appears on several different pages. The output looks like this: http://mysite.com/mypage.php?bluepart=search&keywords=dogs&go=Go I'm trying to do an .htaccess mod rewrite to where any page that passes these variables will get redirected to search_results.php. The bluepart=search and go=Go will always be the same, but keywords can be any number or words. Also, some of my pages are .html and some are .php, when I refer to any page that

Regexp that ignores everything after a question mark symbol

不羁的心 提交于 2019-12-12 01:52:37
问题 This is the full string I'm trying to parse with regular expressions: example.com/newsite.com.html?var=/newsite.com&var=newsite.com I would like to be able to match newsite.com part of the string but only if it does not appear after the ? symbol. Currently, I've only gotten so far: /newsite.com/g Which selects all the instances of newsite.com instead of just the first one. Link to the regexp playground http://regexr.com/3fmre EDIT: Here * represents everything I would like to ignore,

Converting relative URL requests to absolute URL request using mod_rewrite

喜夏-厌秋 提交于 2019-12-12 01:49:41
问题 I have made use of a simple rewrite rule in my .htaccess file to make my URL's pretty. What was once like this: http://somedomain.com/product-details.php?product=MQ==&hash=123456789 Is now this: http://somedomain.com/secure/123456789/MQ==/rings/details/blue-diamond-topaz-ring.php This is all very well, but I have many a PHP file that has all JS and CSS links as relative. Because of the above new pretty URL, these links to JS and CSS are now 5 or 6 directories too deep. My Question: By means

SEO friendly URL issue

痞子三分冷 提交于 2019-12-12 01:48:32
问题 I have a problem in after creating SEO friendly links in my site. here is the .htaccess file codes. RewriteEngine On RewriteRule ^www/category/([0-9]+)/(.*?).html$ www/product/productlist.php?category=$1 [L] preciously i have this link http ://www.mysite.com/www/product/productlist.php?category=00136 now SEO link is this http ://www.mysite.com/www/category/00136/aprons.html this is working okay. and the issue im having is after the page loads all other site links also changed. and those links

Redirect to a directory, preserving the query string

扶醉桌前 提交于 2019-12-12 01:47:01
问题 Any request for / that has a query string is causing a 404 to be triggered. I've found that if I add a /shop/ before the query string, it gets redirected internally and no 404 is triggered. I need a general mod_rewrite rule that will take a URL in the form of: http://www.example.com/?foo=bar and redirect it to: http://www.example.com/shop/?foo=bar where the query string (could be anything) is preserved. 回答1: This will redirect (URL will change) all hits into ROOT (e.g. http://www.example.com/