mod-rewrite

htaccess redirecting specific URL to new domain

江枫思渺然 提交于 2021-02-11 15:29:45
问题 I'm getting myself seriously confused with Rewrite Conditions and Rewrite Rules in my htaccess file. Basically I have a new domain and want to redirect my articles to the new domain. For instance in someone visits old-domain.com/article/XYZ-article-title I want it to redirect to new-domain.com/article/XYZ-article-title. Where I'm getting myself confused is that I only want it to redirect if /article is in the domain (the old domain is still in use for other stuff). 回答1: You can use this code

See apple-app-site-association file in .well-known directory despite RewriteCond

早过忘川 提交于 2021-02-11 12:33:55
问题 In my sites hosted on Dreamhost, the .well-known directory contains an acme-challenge folder along with an .htaccess like this: # Permit access to the challenge files but nothing else Order allow,deny Allow from all RewriteCond %{REQUEST_URI} ^/[.]well-known/acme-challenge/[a-zA-Z0-9_-]+$ RewriteRule .* - [L] RewriteRule .* - [F] Therefore when I put my apple-app-site-association file into .well-known , it isn't seen. How would I modify the .htaccess to permit this? Would I just stick in

Replace URL segment hyphens with spaces using htaccess rewrite rules

杀马特。学长 韩版系。学妹 提交于 2021-02-11 06:19:44
问题 I have a friendly URL as follows: www.dominio.com.br/cidade/sao-paulo And here's my htaccess rewrite rule: RewriteRule ^cidade/(.*)$ busca-cidade.php?cidade=$1 And the SQL query: Select * from cidades where cidade = 'sao-paulo' Is it possible to replace the hyphens with spaces using htaccess and rewrite rules? So the friendly URL will be mapped to: www.dominio.com.br/busca-cidade.php?cidade=sao%20paulo This finished my code, was great, would give to optimize. #################################

Redirecting a dynamic URL to another dynamic URL using htaccess

这一生的挚爱 提交于 2021-02-10 18:47:52
问题 I'm trying to redirect a dynamic URL which is as follows: http://example.com/manage/billing/invoice/all/viewinvoice.php?id=1541 and I need it to redirect to: http://example.com/manage/billing/invoice/1541/ I want to do this using .htaccess I got as far as this but I cannot seem to get it to work: RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /manage/billing/invoice/all/viewinvoice\.php\?id=([^\ ]*) RewriteRule ^ /manage/billing/invoice/all/%1 [L,R=301] Anyone got any suggestions? 回答1: Add this to

Ubuntu 16.04 can't enable .htaccess

我怕爱的太早我们不能终老 提交于 2021-02-10 16:12:51
问题 I'm developing a website local and just switched from Windows to Ubuntu 16.04 - Sadly my .htaccess doesn't seems to work since rewrite rules don't apply and sources can't be found. I activated: sudo a2enmod rewrite rewrite_rule (shared) is listed via: sudo apache2ctl -M My website files (including my .htaccess) are located under /var/www/html My .htaccess Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / # Hide Index IndexIgnore * # Forbid accessing certain sites

Php include() proper Mime-types

╄→尐↘猪︶ㄣ 提交于 2021-02-10 15:56:43
问题 TLDR: I'm looking for a way to serve web resources (css, jpg, etc) from the filesystem that preserves mime-type. I am creating a php wrapper that validates a user from another domain (via a one time token), creates a session and then serves files, several websites in separate directories, inside of a otherwise in accesable directory to that user. I have, so far, used php to handle validation and mod_rewrite to redirect all requests for anything inside of the directory through the wrapper

htaccess - how to apply RegEx patterns on the output of another - encapsulation

无人久伴 提交于 2021-02-10 15:44:24
问题 I'm performing several regular expressions on a string inside a variable in order to clean it up for further use in the htaccess rules, but it seems rather cumbersome to do such simple thing in several lines: RewriteCond %{THE_REQUEST} (?<=\s)(.*?)(?=\s) RewriteRule ^(.*)$ - [E=HREFPATH:%1] RewriteCond %{ENV:HREFPATH} (^.*)?\? RewriteRule ^(.*)$ - [E=HREFPATH:%1] RewriteCond %{ENV:HREFPATH} /(.*) RewriteRule ^(.*)$ - [E=HREFPATH:%1] RewriteCond %{ENV:HREFPATH} (.*)/$ RewriteRule ^(.*)$ - [E

Code Igniter url routing question (using trailing slashes)

与世无争的帅哥 提交于 2021-02-10 14:40:14
问题 I am brand new to codeIgniter. I am very particular about urls on the sites that I develop. Is it possible to create these sorts of urls? Generally sites I develop have an integrated admin interface as well with new, edit or delete added onto the end of the url following a slash. Here are some hypothetical examples (one with an admin url): top level pages (no trailing slash) site.com/about site.com/contact site.com/contact/edit section index lists (lists have trailing slash) site.com/blog/

Code Igniter url routing question (using trailing slashes)

≯℡__Kan透↙ 提交于 2021-02-10 14:38:48
问题 I am brand new to codeIgniter. I am very particular about urls on the sites that I develop. Is it possible to create these sorts of urls? Generally sites I develop have an integrated admin interface as well with new, edit or delete added onto the end of the url following a slash. Here are some hypothetical examples (one with an admin url): top level pages (no trailing slash) site.com/about site.com/contact site.com/contact/edit section index lists (lists have trailing slash) site.com/blog/

When to use [L] flag in mod_rewrite

倾然丶 夕夏残阳落幕 提交于 2021-02-10 13:24:10
问题 Can someone give me an example when to use [L] flag? I'm learning about mod_rewrite moudle in .htaccess file and can't find out when to this flag. 回答1: The L flag simply means to stop applying any rules that follow. Given the same URL, http://example.com/foo/bar?q=blah , and given the rules: RewriteRule ^foo - RewriteCond %{REQUEST_URI} !^/bar.php RewriteRule ^(.*)$ /bar.php?z=$1 The first rule gets applied and the URI gets passed through unchanged (via the - target). The rewrite engine then