mod-rewrite

Remove app/webroot from url

我的梦境 提交于 2019-12-24 05:26:10
问题 I'm trying to remove app/webroot from the url in my CakePHP application using htaccess. We know it can be fixed just by pointing the vhost to the app/webroot folder, but for some reasons the developers over here prefer to fix this using htaccess. Anyone who knows or this is possible? 回答1: Setup your various .htaccess like this: .htaccess in DOCUMENT_ROOT: RewriteEngine on RewriteBase / RewriteRule (.*) app/webroot/$1 [L] .htaccess in DOCUMENT_ROOT/app RewriteEngine on RewriteBase /app/

Rewrite search page query URL with htaccess

淺唱寂寞╮ 提交于 2019-12-24 04:27:30
问题 I want when search form submitted, the URL be like this : localhost/xampp/external/proj3/search/searchquery Instead of this: localhost/xampp/external/proj3/tools/search/search.php?query=searchquery 回答1: You can use this code in your DOCUMENT_ROOT/.htaccess file: RewriteEngine On RewriteBase /xampp/external/proj3 # external redirect from action URL to pretty one RewriteCond %{THE_REQUEST} /search(?:\.php)?\?query=([^\s&]+) [NC] RewriteRule ^ search/%1? [R=302,L,NE] # internal forward from

HTAccess mod rewrite issue using QSA

倾然丶 夕夏残阳落幕 提交于 2019-12-24 04:22:01
问题 I want to add a parameter to a URL but currently it isnt showing in the $_GET global. A snippet from my htaccess file is as below: RewriteRule ^account/blogs/([0-9]+)/([^\s?]+)/?$ /account/blog.php?blogId=$1 [L,QSA] Then in my php code i want to add a link such as: /account/blogs/1/ThisIsWhereTheTitleGoes?delete=1 The wildcard (any char but space) option is for the blog title as i never know what it would be. I know want to add a query string param on the end such as ?delete=1. I however dont

PHP and htaccess redirection: Rewriting yoursite.com/user.php?username=xyz to yoursite.com/xyz

牧云@^-^@ 提交于 2019-12-24 04:11:34
问题 let's say I want to use .htaccess to rewrite the following. Rewriting /user.php?username=xyz to /xyz . I would use: RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1 RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1 The problem is once this is done, how do I access the username in my other links? so /mike/details.php How do I get the value of username ('mike') to automatically be added to the URL so it's like: /username/details.php?username=mike What would I need to

Codeigniter at subfolder and htaccess for inner redirection

别来无恙 提交于 2019-12-24 04:08:21
问题 I have a project with custom engine at backend, I'm trying to hook every request at /somewhere/ with my CodeIgniter. So I put my CI to /www/somewhere/ , configured my CodeIgniter's .htaccess with new RewriteBase, so it now looks like: AddDefaultCharset UTF-8 Options All -Indexes <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /somewhere/ DirectoryIndex index.html index.php RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{REQUEST_URI} ^application.

How to do a specific condition for escaped_fragment with rewrite rule in .htaccess

你。 提交于 2019-12-24 03:53:36
问题 I have urls like that /#!/page1 , I redirect them with : RewriteCond %{QUERY_STRING} ^_escaped_fragment_=%2F(.*)$ RewriteRule ^$ /seo/%1.html [QSA,L] So /#!/page1 read as /_escaped_fragment_=%2Fpage1 is redirected to /seo/page1.html It's work perfectly however I want to redirect the home /#!/ to /seo/index.html which actually redirect to /seo/.html How can I do that? Thanks 回答1: I fixed it with: RewriteCond %{QUERY_STRING} ^_escaped_fragment_=%2F$ RewriteRule ^$ /seo/index.html [QSA,L]

mod_rewrite - how to redirect a mistyped 'pretty' url

試著忘記壹切 提交于 2019-12-24 03:53:31
问题 I have a site written in php which creates 'pretty' urls for each item (on category and search pages) like this, mysite.com/category/slug-for-item-one/1 mysite.com/category/slug-for-item-two/2 The /category/ and /slug/ is dependent upon the numeric id of the item I have mod_rewrite serve the actual content from urls like this: mysite.com/view-item.php?id=1 mysite.com/view-item.php?id=2 The content for each item is retrieved using just the items id. Here's my htaccess: RewriteEngine on

URL Rewrite keeps returning 404 Error

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 03:53:24
问题 I've created a .htaccess file for the URL rewrite, and I tested it using http://htaccess.madewithlove.be/ and it says the URL rewrite is correct, but when testing the page keeps giving me a 404 error. Here is the .htaccess: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^article/(.*)$ /article/index.php?id=$1 The URL rewrite I need is the following: http://www.mydomain.com/article/test // To redirect to: http://www.mydomain.com/article/index.php?k=test Can

How to do a specific condition for escaped_fragment with rewrite rule in .htaccess

做~自己de王妃 提交于 2019-12-24 03:53:07
问题 I have urls like that /#!/page1 , I redirect them with : RewriteCond %{QUERY_STRING} ^_escaped_fragment_=%2F(.*)$ RewriteRule ^$ /seo/%1.html [QSA,L] So /#!/page1 read as /_escaped_fragment_=%2Fpage1 is redirected to /seo/page1.html It's work perfectly however I want to redirect the home /#!/ to /seo/index.html which actually redirect to /seo/.html How can I do that? Thanks 回答1: I fixed it with: RewriteCond %{QUERY_STRING} ^_escaped_fragment_=%2F$ RewriteRule ^$ /seo/index.html [QSA,L]

Can I used mod_rewrite to change file extensions? .jpeg to .jpg for example

╄→гoц情女王★ 提交于 2019-12-24 03:42:56
问题 I am looking to use Apache mod_rewrite to serve a file as .jpg instead of .jpeg. Is this possible? 回答1: Try this: RewriteEngine on RewriteRule ^(.+)\.jpeg$ $1.jpg 回答2: You can rewrite the jpeg extension to jpg using the following rule in htaccess : RewriteEngine on RewriteRule ^(.+)\.jpeg$ /$1.jpg [L] 来源: https://stackoverflow.com/questions/1479167/can-i-used-mod-rewrite-to-change-file-extensions-jpeg-to-jpg-for-example