mod-rewrite

Apache mod rewrite .htaccess to get params

大憨熊 提交于 2020-01-07 05:35:18
问题 How can i catch the prams after file name with extension like service.php/view1 for ex: service.php/newview1 I want to get it like service.php?view=newview1 how do i write mod-rewrite for this I tried like RewriteRule ^services.php/?([a-zA-Z_]+)$ /services.php?category=$1 its not matching the service.php/newview1 回答1: When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using

Post variables not sending : php / apache / codeigniter

和自甴很熟 提交于 2020-01-07 05:27:39
问题 I got a problem with an application built in codeigniter. The $_POST variables are not working, var_dump($_POST) returns array(0) In online environment works fine, so it's localhost problem. I think its the apache conf or the .htacces conf, I'm adding the .htacces used in this project. Any help its really appreciated, thanks. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ $1 [L,R=301] RewriteCond %{REQUEST_URI} ^system.*

how to prevent users having access to a particular directory

主宰稳场 提交于 2020-01-07 05:01:09
问题 I have a directory named "includes" containing information about my database and some other important files that users should not access. I want to use an .htaccess file to redirect requests that begin with "/includes" to errors/403.html . This is my code but it does not work. What's the problem?! RewriteEngine On # Turn on the rewriting engine RewriteRule ^/includes/([a-zA-Z]+)/?$ /errors/403.html [NC,L] 回答1: If your config files are php, you can just place empty index.php in that directory

Redirect existing file to different url using mod_rewrite

安稳与你 提交于 2020-01-07 04:28:09
问题 I'm trying to use mod_rewrite to redirect an existing file to a different URL. I'm using the following and it has no effect. I've tried several variations of which don't work. RewriteEngine on AddHandler x-httpd-php .php3 # AddHandler x-httpd-php5 .php .php4 # This file exists, but this redirect doesn't work RewriteRule ^show.php?id=review-1$ /review/1/super-baseball-2020/ [R=301,L] Does it by chance have something to do with the url params? 回答1: You cannot have query string in RewriteRule.

.htaccess mod_rewrite remap without redirection?

雨燕双飞 提交于 2020-01-07 04:18:06
问题 I'm using the following to redirect http://example.com/somedir/?_escaped_fragment=key=val to http://example.com/somedir/static/?key=val. RewriteBase / RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$ RewriteRule ^(.*)$ - [E=BASE:%1] RewriteCond %{QUERY_STRING} ^_escaped_fragment=(.*)$ RewriteRule ^(.*)$ %{ENV:BASE}static/?%1 [L,R=302] How can I hide the URL change? I'd like to avoid using mod_proxy, if possible. 回答1: Simply remove the ,R=302 for an internal redirect, see: http://httpd.apache

Fastest way to redirect missing image files

烂漫一生 提交于 2020-01-07 04:12:25
问题 I have an on-the-fly thumbnailing system and am trying to find the best way to make sure it's as fast as possible when serving up images. Here is the current flow: User requests thumbnail thumbnails/this-is-the-image-name.gif?w=200&h=100&c=true htaccess file uses modrewrite to send requests from this folder to a PHP file PHP file checks file_exists() for the requested image based on the query string values If it does: header('content-type: image/jpeg'); echo file_get_contents($file_check_path

Apache's mod_rewrite failing to remove trailing slash

廉价感情. 提交于 2020-01-07 03:36:06
问题 I have a XAMPP Apache server, and have added a configuration file to rewrite URLs with a trailing slash and redirect to their slash-less counterparts. Therefore, a url like http://example.com/the-audio/ gets redirected to http://example.com/the-audio . The problem is, it's not working when the directory name is only one word. So, http://example.com/audio/ does not get it's slash removed. This is really strange for me, and checking the logs it appears as though the rule isn't matched in this

Need Apache rewrite rule to change part of url

旧城冷巷雨未停 提交于 2020-01-07 03:00:33
问题 I have urls like this: www.example.com/ index.php/category-5 /subcategory/page I want to rewrite to: www.example.com/ category /subcategory/page I.e. I want to remove the "index.php/" and also remove the "-5", but keep the rest. I am in way over my head with Apache. I normally just write plain simple php code. I tried this and it didn't work: RewriteRule ^index.php/category-1/(.*)$ /category/($1) [NC] Thanks Also, please, if we could make it a permanent redirect that would be great. 回答1: Don

htaccess Mod_rewrite with accents

∥☆過路亽.° 提交于 2020-01-07 02:58:05
问题 I have an international website, and a section of the website, used to create a new person, has the person's name in the URL. I need that URL to allow accents as well as some special characters like à Right now I'm using: RewriteRule ^([áéíóúñÁÉÍÓÚÑäëïöüÄËÏÖÜçÇA-Za-z-]+)/?$ /newPerson.php?person=$1 [NC,QSA] UPDATE: This works, but is not a very elegant approach. I am asking for a better way of matching all letters (lower and uppercase) with all possible accents à, á, ä... etc, if there is

How to use mod_rewrite with anchors but no [R=301]

半世苍凉 提交于 2020-01-07 02:53:03
问题 I have a website build on jQuery scrollTo plugin. Each page is accessible via anchor's, ie. www.domain.com/#page-one and deeper www.domain.com/#page-one--some-content . I'd like to create rule with mod_rewrite so address like www.domain.com/page-one or www.domain.com/page-one/some-content point to the above one. Its quite easy with [R=301] flag but I need my "clean" address /page-one/some-content to stay in address bar not changing to #page-one--some-content . Why I need to change them?