.htaccess

Rewrite query string parameter into URL Apache

牧云@^-^@ 提交于 2020-01-15 18:52:00
问题 URL coming into Apache: localhost:8888/game?level=0 URL that should be coming out of apache: localhost:8888/level0/game Could someone kindly help me to create this rewrite ? Tried to solve it with following: RewriteEngine On RewriteRule ^game\/+(.*?)\?+level=+([0-9]+) /level$2/$1 [L,QSA] With no luck since it does not match. Thanks, Peter 回答1: To be able to capture values from the query string, you need a RewriteCond %{QUERY_STRING} directive, so that captured group will be available as %n

Rewrite query string parameter into URL Apache

僤鯓⒐⒋嵵緔 提交于 2020-01-15 18:50:50
问题 URL coming into Apache: localhost:8888/game?level=0 URL that should be coming out of apache: localhost:8888/level0/game Could someone kindly help me to create this rewrite ? Tried to solve it with following: RewriteEngine On RewriteRule ^game\/+(.*?)\?+level=+([0-9]+) /level$2/$1 [L,QSA] With no luck since it does not match. Thanks, Peter 回答1: To be able to capture values from the query string, you need a RewriteCond %{QUERY_STRING} directive, so that captured group will be available as %n

Rewrite query string parameter into URL Apache

时间秒杀一切 提交于 2020-01-15 18:50:35
问题 URL coming into Apache: localhost:8888/game?level=0 URL that should be coming out of apache: localhost:8888/level0/game Could someone kindly help me to create this rewrite ? Tried to solve it with following: RewriteEngine On RewriteRule ^game\/+(.*?)\?+level=+([0-9]+) /level$2/$1 [L,QSA] With no luck since it does not match. Thanks, Peter 回答1: To be able to capture values from the query string, you need a RewriteCond %{QUERY_STRING} directive, so that captured group will be available as %n

.htaccess redirect only working for part of the URL

此生再无相见时 提交于 2020-01-15 17:48:11
问题 I'm trying to redirect a bunch of URLs from an old site to the shiny relaunched site. My .htaccess is working with the first level of directories (i.e. example.com/directory is redirecting to example.com/newdirectory), but I'm having issues redirecting beneath that. Here's an example of one that's not working: Redirect 301 /Expertise/QuantitativeResearch/ /services/quantitative-research/ This goes to example.com/services/QuantitativeResearch - so the Expertise directory is being redirected,

mod_rewrite for query string

孤人 提交于 2020-01-15 15:54:27
问题 I have got 3 cases of mod_rewrite: http://www.domain.com/location/albania/tirana/tirana-airport http://www.domain.com/location/albania/tirana http://www.domain.com/location/albania The actual url for all these cases would be: http://www.domain.com/page.php?country=albania&city=tirana&location=tirana-airport Can you describe a mod_rewrite rule which can work for all 3 cases? Right now if a city or location is missing, the page returns 404. It only works if all the 3 parameters are present.

Trailing dots being stripped from URL

巧了我就是萌 提交于 2020-01-15 12:37:13
问题 I've got a url - http://callisto/news/1st_February_is_here... - which has three trailing dots, but by the time it gets passed through mod_rewrite and reaches the script (in $_GET) the dots have been removed (but the rest of the string is OK). This is the htaccess rule: RewriteRule ^([^/]+)/(.*)$ index.php?__action=site&__filter=$1&__page=$2 [L,QSA] Thanks. 回答1: I take it you are using the title of a post or something similar as the third position in your URI. Due to the fact that you could

htaccess rewrite slug in a url

天涯浪子 提交于 2020-01-15 12:33:46
问题 I've searched and searched for help on a rewrite rule but nothing seems to match specifically what I'm trying to do, hopefully someone can help? I'm trying to replace a slug in a url that could have various other possible slugs before and after it. e.g. http://www.example.com/slug/old_slug to http://www.example.com/slug/new_slug or /slug/old_slug/slug to /slug/new_slug/slug or /slug/old_slug/slug/slug to /slug/new_slug/slug/slug or finally: /slug/old_slug/slug?param=1&param=2 to /slug/new

Rewrite single and consecutive underscores to dashes

这一生的挚爱 提交于 2020-01-15 12:33:31
问题 I'm trying to rewrite URLs with underscores in to dashes for a shopping site. Product names currently have underscores for spaces. A typical URL is as follows: http://test.local/category-name/product_name_a My current .htaccess is as follows and successfully rewrites this to: http://test.local/category-name/product-name-a RewriteEngine On RewriteBase / #Rewrite Underscores to dashes RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^_]*)_([^_]*)$ $1-$2 [L,R=302,NE] RewriteCond %{REQUEST

htaccess rewrite slug in a url

淺唱寂寞╮ 提交于 2020-01-15 12:33:19
问题 I've searched and searched for help on a rewrite rule but nothing seems to match specifically what I'm trying to do, hopefully someone can help? I'm trying to replace a slug in a url that could have various other possible slugs before and after it. e.g. http://www.example.com/slug/old_slug to http://www.example.com/slug/new_slug or /slug/old_slug/slug to /slug/new_slug/slug or /slug/old_slug/slug/slug to /slug/new_slug/slug/slug or finally: /slug/old_slug/slug?param=1&param=2 to /slug/new

mod_rewrite is preventing my form to be submitted as desired

笑着哭i 提交于 2020-01-15 12:27:28
问题 I have created a www.example.com and m.example.com. The m.example.com resides inside the htdocs/m/ folder. I am also deleting the '.php' extensions using .htaccess. I am having the below codes on the root directory: RewriteCond %{REQUEST_METHOD} =POST RewriteRule ^ - [L] # Redirect external .php requests to extensionless url RewriteCond %{THE_REQUEST} \s/+(.*?/)?(?:index)?(.*?)\.php[\s?] [NC] RewriteRule ^ /%1%2 [R=302,L,NE] #mobile RewriteCond %{HTTP_HOST} ^m\.example\.com$ [NC] RewriteCond