mod-rewrite

.htaccess rewrite GET variables w/ 301 redirect

倾然丶 夕夏残阳落幕 提交于 2019-12-25 05:37:30
问题 I'm trying to simultaneously do a 301 redirect and imporve my url structure by stripping the get variables. I recently updated my website and Google has some old pages cached that have since moved. The structure looks like this wwww.domain.com/locations.asp?zip=10001 <---OLD URL wwww.domain.com/locations/?zip=10001 <---NEW URL Right now I'm redirecting the old page to the new using the following line in my .htaccess file: Redirect 301 /solar_panel_systems_zip.asp /zip-code/ The above works

Generating SE friendly URL .htaccess mod rewrite

瘦欲@ 提交于 2019-12-25 05:36:50
问题 I've a URL which get file name through get method and display it on the page. tvchaska.info/i/ this is the page and when u click any image it will go to say http://tvchaska.info/i/output.php?i=http://brothertattoo.co.uk/wp-content/uploads/2011/09/Sexy-Girl-Tattoo.jpg I want my this URL to be rewritten as tvchaska.info/i/Sexy-Girl-Tattoo.html I tried following rule but it is not working RewriteEngine On RewriteRule ^([^/]*)\.html$ /output.php?i=$1 [L] Can any one plz help me to attain this plz

Rewrite URL so that query string is in path

爷,独闯天下 提交于 2019-12-25 05:33:07
问题 I'm trying to get the following path: /faculty/index.php?PID=FirstLast&type=alpha To rewrite to this: /faculty/FirstLast Am I correct to assume the following would be acceptable to put in .htaccess? # Rewrite old URLS RewriteCond %{QUERY_STRING} ^PID=([0-9a-zA-Z]*)$ RewriteRule ^/faculty/index.php$ /faculty/%1 [R=302,L] I'm okay to throw away any other query string variables. I'm applying these rules at the .htaccess file level. This project is a migration from an older system into Drupal.

clean url using mod_rewirte

前提是你 提交于 2019-12-25 05:32:54
问题 How i can convert this url www.domain.com/post.php?view=36&title=slug-of-post-title into clean url as www.domain.com/36-slug-of-post-title Help me, if you know where i can get a better understanding about mod_rewrite please provide website address thanks 回答1: RewriteEngine On RewriteRule ^([0-9]+)-(.*)$ /post.php?view=$1&title=$2 [QSA,L] http://www.4webhelp.net/tutorials/misc/mod_rewrite.php 回答2: This should do: RewriteEngine On RewriteRule ^(\d+)-(.*)$ post.php?view=$1&title=$2 [QSA,L] 回答3:

Grouping file extensions for re-writing URL's [.htaccess]

痞子三分冷 提交于 2019-12-25 05:32:28
问题 How can I group these two together; is it like ".(html|php)$" - please provide the code. Note, the answer should work for all file extensions: what is your thoughts on removing every file extension; comment on the code used - as it is rare to find. RewriteCond %{THE_REQUEST} ^GET\ (.*)\.html\ HTTP RewriteRule (.*)\.html$ $1 [R=301] RewriteCond %{REQUEST_FILENAME}.html -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1\.html [L] RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP RewriteRule (

htaccess mod_rewrite multiple paths to query string

我的未来我决定 提交于 2019-12-25 05:26:13
问题 I've been searching but I can't quite find what I'm after. I'm trying to find an elegant way to redirect my url path to the query string via htaccess and mod_rewrite. The problem is that the path does not have a fixed amound of sub dirs and could be huge. i.e. http://example.com/sub1/sub2/sub3/sub4/sub5/sub6/sub7... Currently I just have a load of rules in my htaccess to capture these... RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/? /index.php?sub[]=$1&sub[]=$2&sub[]=$3&sub[]=$4&sub[

htaccess redirect when directory exists [duplicate]

∥☆過路亽.° 提交于 2019-12-25 05:19:23
问题 This question already has answers here : htaccess redirect fails to redirect when directory exists (3 answers) Closed 3 years ago . For making friendly URLs, Following is the htaccess code applied: RewriteEngine On RewriteCond %{THE_REQUEST} /.+?\.php[\s?] [NC] RewriteRule ^ - [F] RewriteRule ^([^/\.]+)$ index.php?id1=$1 [NC,L,QSA] RewriteRule ^([^/\.]+)/([^/\.]+)$ index.php?id1=$1&id2=$2 [NC,L,QSA] This now works for: mydomain.com/pages to mydomain.com/index.php?id1=pages mydomain.com/pages

htaccess physcially redirect in case of 404

时光总嘲笑我的痴心妄想 提交于 2019-12-25 05:09:27
问题 To start off I know how to do a simple redirect to a 404 when a page doesn't exist with. ErrorDocument 404 /index.php Is what I want to do is a physical redirect to the index page. So if a user types in mydomain.com/abc and that page doesn't exist it does an actual redirect TO the index page. I don't want the url to remain the same with the bad address. Yes I know its not a big deal but it bugs me. I could accomplish this by having a custom 404 page redirect to the homepage but I don't want

htaccess *.php to *.html object not found error

蓝咒 提交于 2019-12-25 05:09:06
问题 I am trying to transform URLs from index.php to index.html , servicii.php to servicii.html and so on. I wrote in my .htaccess file, which is in my site root the following code: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^(.*)\.php$ $1.html [R=permanent] </IfModule> ?> But when I follow "Prima pagina" (Home) or "Servicii" (the only 2 pages created on site) it gives me a 404 error Also, I have the code <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /fetesti/

“http://” in query string does not work

断了今生、忘了曾经 提交于 2019-12-25 05:01:53
问题 UPDATE: I tested in a subdomain - no .htaccess and PHP. I created a index.html and tried accessing /?p=http:/ and /?p=http:// . I got this error for /?p=http:// Forbidden You don't have permission to access / on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache Server at test.example.com Port 80 This rules out any PHP or mod_rewrite problem. What is wrong with Apache? Case 1 (does not work): mysite.com?p=http://