url-rewriting

Htaccess Querystring rewrite

十年热恋 提交于 2019-12-02 06:31:59
I have URLs like /?test that I want to rewrite to /page.php?page=test I tried like this but for some reason it doesn't work. RewriteRule ^\?([a-z0-9\-\+]{3,20})/?$ /page.php?page=$1 [NC,QSA] What am I doing wrong? The query string can only be tested with the RewriteCond directive . The RewriteRule pattern is only tested against the URL path (in .htaccess files the URL path without the per-directory prefix). So try this: RewriteCond %{QUERY_STRING} ^[a-z0-9-+]{3,20}$ [NC] RewriteRule ^$ /page.php?page=%0 [QSA] 来源: https://stackoverflow.com/questions/1337152/htaccess-querystring-rewrite

Remove parameter from URL viac .htaccess

三世轮回 提交于 2019-12-02 06:27:17
I need advice how to remove a parameter from the url using. Htcaccess The condition is as follows: redirect url from: http://example.com/?movie=2&ref=nf to: http://example.com/?movie=2 I tried several options but I have not come to nothing Thank you for your ideas / advice. THX. Try adding the following to the .htaccess file in the root directory of your site. RewriteEngine on RewriteBase / #If request contains ref param RewriteCond %{THE_REQUEST} \?([^&\ ]+)&ref= [NC] #redirect to URL without the ref param RewriteRule ^ %{REQUEST_URI}?%1 [L,R=301] 来源: https://stackoverflow.com/questions

Rewrite dynamic url structure with .hataccess

青春壹個敷衍的年華 提交于 2019-12-02 06:12:29
I've tried to rewrite the dynamic URL (below) to a slightly different structure; either does not work or I am not sure if it is correct: Old URL (URL#1): index.php?lang=AAA&zone=BBB&city=CCC&str=DDD&search=EEE New URL (URL#11): index.php?lang=AAA&country=BBB&place=CCC&street=DDD *basically changed the names and the "search" string is not important any more what I am trying to achieve is redirecting all visitors from (old) dynamic URL#1 to (new) dynamic URL#11 In a second step, after all search engines show the new urls and we finished all test that are easier with non-sef urls, we would like

REQUEST_URI not matching explicit path and filename

泪湿孤枕 提交于 2019-12-02 05:41:22
Really stumped, because form and syntax seem fine. RewriteCond for REQUEST_URI is not matching the explicit path and filename. When isolated, RewriteCond for REQUEST_FILENAME matches just fine. I have verified using phpinfo() that REQUEST_URI contains the leading slash, and have tested without the leading slash, also. The goal here is to know that the request is for this file and, if it doesn't exist, then throw a 410. RewriteCond %{REQUEST_URI} ^/dir1/dir2/dir3/v_9991_0726dd5b5e8dd67a214c0c243436d131_all\.css$ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ - [R=410,L] I don't want to

URL-rewriting with index in a “public” folder

Deadly 提交于 2019-12-02 05:36:22
I’m a newcomer in the development world. I desperately try to get the good URL. I checked the site for similar problems but I can’t find exactly what I need. Or I do it badly. Here is the situation: I set up a project for a site whose the index.php file is in a folder named Public. To be clearer, here is the URL I have now to reach the homepage of the built site: http:// Domain Name.com/ Folder / Name of the site/public My concern is about the folder Public: I don’t want it appears in the URL. Here is the URL I’d like to get: http:// Domain Name.com/ Folder / Name of the site In fact, I’d like

What is the difference in operation between . and ^ and ^(.*)$?

独自空忆成欢 提交于 2019-12-02 05:30:55
What is the difference in operation between: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [L] and RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] and RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L] I know that "." means any character and "^" beginning of string. Thanks for reply! First let's understand how landing page is matched. For landing page URI pattern is ^$ in .htaccess, ^/$ in Apache config. Thus you can safely use ^/?$

Friendly URLs and Query Strings

烈酒焚心 提交于 2019-12-02 05:29:31
In my project (ASP.NET Web Forms) I want to use Friendly URLs , installed from NuGet. I registered route in global.asax file: Public Shared Sub RegisterRoutes(routes As RouteCollection) routes.MapPageRoute("Route", "default/{id}", "~/default.aspx?id={id}") End Sub With this code, I can use default/123 instead of default?id=123 . I want to add name, assigned to the id, in the url. So I can have url like this: default?123-Firstname-Lastnam. Name is saved in database, in single column. How can I add second parameter (name) to the url, add symbol - and display it without letters like this: řčš

Htaccess - Rewrite from http to https and www to non-www

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 05:06:11
I am trying to rewrite form http to https and www to non-www urls. Basically if someone goes to http://www.example.com they need to be redirected to https://example.com and all other instances of wrong urls ( http://example.com , etc.). I tried to do this by piecing suggestions together: RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{HTTP_HOST} ^www\.garrysun\.com [NC] RewriteRule ^(.*)$ https://garrysun.com/$1 [L,R=301] But when I check the URL in a redirect checker I get errors... http://garrysun.com works fine and

SEO friendly URL's with .htaccess

别说谁变了你拦得住时间么 提交于 2019-12-02 05:04:45
问题 Can anybody please help me with some URL rewriting? I have (for example) these pages: www.mydomain.com/test/gallery.asp?id=2 www.mydomain.com/test/gallery.asp?id=3 and want them to be requested as: www.mydomain.com/photos/people www.mydomain.com/photos/wildlife I'm using IIS and at first my hosting provider was using ISAPI_Rewrite with a httpd.ini file, now they have switched to Helicon Ape with a .htaccess file. See: http://www.isapirewrite.com/ and http://www.helicontech.com/ape/ I tried it

PHP $_GET and .htaccess rewrite

こ雲淡風輕ζ 提交于 2019-12-02 04:54:31
I know this is probably a common question and has been asked before but .htacess looks foreign to me and I can't seem to get this to work from looking at previous questions. I have a index script that searches and the syntax is: .../listing/?field=property_type&query=retail I simply want to rewrite this to: .../listing/{field}/{query} One other catch, I have some fields that are boolean.. for example: .../listings/?forlease=1 So in this case I just use isset() but would like to rewrite this to: .../listings/forlease/ Thanks for your help as always! Stack Overflow rocks! EDIT: I see some good