mod-rewrite

RewriteCond for url with parameters

老子叫甜甜 提交于 2019-12-20 09:37:44
问题 I've got a problem to rewrite an url. I want this : http://www.foo.com/test.php?u=s1&id=12345&img=12 to http://app.foo.com/12345-s1-12.test First parameter u is a string, parameters id and img are integers. I've started with something like that : RewriteCond %{REQUEST_URI} ^/test.php?u=(.*)&id=(.*)&img=(.*)/ [NC] RewriteRule (.*) http://app.foo.com/%2-%1-%3.test [QSA,R=301,L] Thanks :) EDIT : Still doesn't work but i'm close! RewriteCond %{REQUEST_URI} ^/test.php [NC] RewriteCond %{QUERY

How to rewrite my URL to items/category/item-name-itemid using mod rewrite?

*爱你&永不变心* 提交于 2019-12-20 07:30:35
问题 I want to rewrite my urls in this form: /items/category/item-name-id (the id is a number). Now my URL look like this: items.php?cat=category&name=item-name&id=12321 Oh and where I need to place the code for mod-rewrite ? 回答1: In .htacces: RewriteEngine On # Enable these for debugging, disable when done (it's "expensive") # RewriteLog /var/log/apache2/rewrite.log # RewriteLogLevel 9 # if the requested URI doesn't point to an existing file or directory RewriteCond %{REQUEST_FILENAME} !-f

wordpress .htaccess rewrite url

时光怂恿深爱的人放手 提交于 2019-12-20 07:25:11
问题 I am developing quiz section for my wordpress site. I have W3 total cache installed on my site. I want to put quiz on http://www.example.com/quiz/seo-friendly-title/id and rewrite htaccess to redirect the url to http://www.example.com/quiz?title=seo-friendly-title&quiz-id=id The quiz section is developed as wordpress template and a blank page is made using this template. This is .htaccess I wrote. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^quiz/([\w\d\-]+)/(\d]+)$

HTAccess - Confusing clean url's

人盡茶涼 提交于 2019-12-20 07:16:35
问题 If i wanted to simply redirect /clients/page/ to /clients.php?view=page i would use something as simple as this, it works great. Options +FollowSymlinks RewriteEngine on RewriteRule ^clients/([^/]+) /clients.php?section=$1&$2 [NC] If i had for example, a url like: /clients/page/?name=Tom how could i transfer those HTTP GET variables to a simple url like /clients.php?view=page&name=Tom i have tried and failed. Any ideas? 回答1: I think you can use the [QSA] flag, which stands for Query String

Redirect to another folder

Deadly 提交于 2019-12-20 07:14:08
问题 I read this .htaccess rewrite to redirect root URL to subdirectory and i'm trying to achieve the same things. The solution with most up votes was: RewriteEngine on RewriteCond %{HTTP_HOST} ^example\.com$ RewriteRule (.*) http://www.example.com/$1 [R=301,L] RewriteRule ^$ store [L] Now, looking at the comments it seems to be working good. The problem is that I'd like not to hardcode any path (as instead provided above "www.example.com"). I'd like that my .htaccess inside projectname/ redirects

Force HTTPS and Non-WWW with .htaccess for CloudFlare Users

北城余情 提交于 2019-12-20 06:41:51
问题 I am using CloudFlare and I want to force HTTPS and Non-WWW by using .htaccess I know there are many examples online already, but for CloudFlare users, normal redirect may cause redirect loops. The closest answer is this one: https://stackoverflow.com/a/34065445/1254581 But it only force HTTPS and I need to force non-WWW too. Please help to edit this rules: RewriteEngine On # If we receive a forwarded http request from a proxy... RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR] # ...or just a

How to name file and directory the same with .htaccess rewrite rules?

北战南征 提交于 2019-12-20 06:36:28
问题 I am trying to work on my "pretty-urls" and I'll be the first to admit I really don't know what I'm doing. I'm trying to wrap my head around it though. So what I am trying to do is have a file.php, but then also have a directory called file. That way I can go to www.example.com/file and it should pull up file.php. But I also want to be able to go to www.example.com/file/subfile and it should go to subfile.php IN the file directory. Right now, I'm able to get rid of ".php" on all files and I

Htaccess Remove part of URL

▼魔方 西西 提交于 2019-12-20 06:35:22
问题 I have this URL: http://www.website.nl/pagina/4/wie-ben-ik.html "pagina" is a real php document. "4" is the id of the webpage, with the id I get the results from the database. Can I change this URL to http://www.website.nl/wie-ben-ik with htaccess? Thank you! 回答1: You have to pass the id some way or the other if you want it to query from the database. Either use a query string (name-value pair) or have it in the URI like your are doing above. If you do not want pagina in your URI you can have

How to name file and directory the same with .htaccess rewrite rules?

只愿长相守 提交于 2019-12-20 06:32:24
问题 I am trying to work on my "pretty-urls" and I'll be the first to admit I really don't know what I'm doing. I'm trying to wrap my head around it though. So what I am trying to do is have a file.php, but then also have a directory called file. That way I can go to www.example.com/file and it should pull up file.php. But I also want to be able to go to www.example.com/file/subfile and it should go to subfile.php IN the file directory. Right now, I'm able to get rid of ".php" on all files and I

Adding mod-rewrite to an existing PHP website

放肆的年华 提交于 2019-12-20 06:26:06
问题 I am updating a php app, which currently does not use url rewriting. The aim is to hide file extensions. The general structure of the website is as follows root/ index.php login.php page1.php page2.php page3.php page4.php page5.php page6.php page7.php page8.php subfolder/ index.php validpage.php images/ css/ The subfolder folder in the above structure is unique in that it is the only subfolder containing php files.All of the other files are in the root folder. I have been through these