mod-rewrite

htaccess - Removing last segment after unique ID number in url

一笑奈何 提交于 2019-12-25 09:05:01
问题 In case there is something after a string that looks like this "/UniqueID (numbers only)/", e.g.: "/455/", in my url, I want to delete it. Here is what I have in my htaccess file right now: RewriteCond %{REQUEST_URI} m.* RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^m(.*)$ articles.php?$1 [T=application/x-httpd-php,L] (I guess it adds a hidden extention "articles.php". So, if my url looks like this: www.mondomaine.com/m/234/ - no change needed for the

conditional htaccess?

爷,独闯天下 提交于 2019-12-25 08:46:33
问题 lets say i have the following GET variables available: state city bedrooms bathrooms type price now i want them to come out like this: mysite.com/state/city/#-bedrooms/#-bathrooms/type/price however, i want this to work so that if one of these variables are not there, it will still work i.e.: mysite.com/state/city/#-bedrooms or: mysite.com/state/#-bedrooms/price how do i do this? 回答1: You can make parts of a regex optional using the ? quantifier. # state city bedrooms bathrooms RewriteRule ^(

.htaccess question - URL-rewriting

旧街凉风 提交于 2019-12-25 08:37:26
问题 I have an issue with URL-rewriting in .htaccess. Here is .htaccess file: RewriteEngine On RewriteBase /community/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^view-all-results$ forums/index.php?view=view-all-results [R=302] RewriteRule ^view-all-results/$ forums/index.php?view=view-all-results [R=302] I need to rewrite url like " /community/view-all-results?u=2 " to " community/forums/index.php?view=view-all-results&u=2 ". But according to the above

Wordpress permalinks do not work. No errors

痴心易碎 提交于 2019-12-25 08:28:46
问题 I'm running a blog on subdomain. "blog.ourcompanyname.com". Wordpress folder is located under "/var/www/wordpress" Apache instance is running on 8081 port (manually configured) and being proxy passed by Nginx (which runs on 80 port). The reason we need NGINX is because we are running a second application on the same server (VPS, Ubuntu 12.04 LTS), and it is not a "PHP" application. Now, everything is working smooth: you can access different pages, static content (pictures, etc) are working.

making clean url with htaccess

爱⌒轻易说出口 提交于 2019-12-25 08:19:21
问题 I am trying to make clean url with htaccess I have a profile.php page and I get user domain name to display his page now if the user for example hit www.XXXX.com/domain I will display his main page it is equivalent to www.XXXX.com/profile.php?id=domain without htaccess file I used this code and its working very fine Options +FollowSymLinks RewriteEngine On RewriteCond %(SCRIPT_FILENAME) !-d RewriteCond %(SCRIPT_FILENAME) !-f RewriteRule ^(\w+)$ ./profile.php?id=$1 RewriteRule ^(\w+)/$ .

How to remove // from URL using htaccess

牧云@^-^@ 提交于 2019-12-25 08:09:11
问题 How to remove / from URL if they appear twice or thrice. Like: www.site.com/mauritius_holiday_rentals/search//2/Pool-Villa should become www.site.com/mauritius_holiday_rentals/search/2/Pool-Villa and www.site.com/mauritius_holiday_rentals/search///Beach-Villa should become www.site.com/mauritius_holiday_rentals/search/Beach-Villa 回答1: You can use RedirectMatch directive With Regex, so If an additional forword slash was added accidently to the url ,then you have a chance to make it optional or

mod_rewrite query string

爱⌒轻易说出口 提交于 2019-12-25 08:04:02
问题 I have a query string like search.php?id=12&keyword=abc&api=gIUTG6898 And I want the URL to be like this: search/?id=12&keyword=abc&api=gIUTG6898 Now I found a lot of solutions but they are limited to only one variable in the query string. Thanks in advance 回答1: It's not that complicated, since you just want to 'transfer' the query string. You can ignore it in the RewriteRule. RewriteRule ^search/?$ search.php [QSA] This just rewrites 'search/' to 'search.php'. 回答2: Since you are wanting to

How to Redirect Non WWW Website to WWW Version on Unmanager Server?

你。 提交于 2019-12-25 07:49:23
问题 I have hosted my Website on Digital Ocean & Installed Wordpress through Serverpilot. Current Home Page URL is www.xyz.com & xyz.com is also redirecting on it. But When I open xyz.com/test-post its not rediecting on www.xyz.com/test-post. How can I Redirect it ? 回答1: Set the www version of URL in WordPress Address (URL) and Site Address (URL) fields present under WordPress (backend) and then write this in your .htaccess file # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On

RewriteRule - loop redirection

余生颓废 提交于 2019-12-25 07:46:49
问题 i need help with this 2 rewrite rules: RewriteEngine On RewriteBase / # folder/script.php?A=1&B=2 -> xyz/1/2 (REDIRECT) RewriteCond %{QUERY_STRING} ^A=([^&]+)&B=([^&]+)$ RewriteRule ^folder\/script\.php$ /xyz/%1/%2? [R=301,L] # xyz/1/2 -> folder/script.php?A=1&B=2 (REWRITE) RewriteRule ^xyz\/([^\/]+)\/([^\/]+)$ /folder/script.php?A=$1&B=$2 [L] First I need "REDIRECT" FROM: efectorelativo.net/folder/script.php?A=1&B=2 TO: efectorelativo.net/xyz/1/2 Then i need "REWRITE" not "REDIRECT" FROM:

Custom error page failed to load after editing htaccess

折月煮酒 提交于 2019-12-25 07:30:02
问题 I edited my htaccess file to rewrite mysite.com/page to mysite.com/page.php and to show 404 error page if a user requested mysite.com/page.php instead of mysite.com/page I also added my own custom 404 error page But when I requested mysite.com/page.php , the error page shown was Apache default 404 error page (instead of my custom error page), with additional error info: Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.