mod-rewrite

mod_rewrite with ? in the original URL like YouTube

蹲街弑〆低调 提交于 2020-06-01 03:41:55
问题 Ok I want to simulate the YouTube URL and redirect it to my real URL. Reason being is I used a random string to make video ID's so they aren't guessable by sequence. I have the links as so http://www.mysite.com/watch?v=Dxdotx3iT1 and want to redirect to http://www.mysite.com/index.php?page=videos&section=view&v=Dxdotx3iT1 Can't seem to figure out the mod rewrite. Also using a ? I believe tells it to do something. Any help would be appreciated. 回答1: You need to adjust your RewriteRule to

How do you write an htaccess RewriteRule to make my urls work like youtube?

家住魔仙堡 提交于 2020-05-28 12:05:33
问题 I have a php file called index.php, in this file I have a php variable $video which receives its information from a $_GET["v"] request. If I use https://www.example.com/index.php?page=video&v=UnIq3Id I can fill the $video variable. When I write a RewriteRule, which I have tried; #FIRST RULE TRIED RewriteRule ^watch$ index.php?page=video [QSA] #SECOND RULE TRIED RewriteCond %{QUERY_STRING} ^v=(.+) RewriteRule ^watch /index\.php?page=video&v=%1 [QSA,R=301,L] I got these rules from mod_rewrite

htaccess howto rewrite an encoded slash in url

空扰寡人 提交于 2020-05-16 13:55:52
问题 I have URL with an encoded slash ( %2F ) and I cannot get rewrite rules to catch this correctly. My URL is: http://example.com/some-path/description%2Frest-of-description/1101 I've tried rewrites like:- # is the %2F interpreted as a path separator RewriteRule ^some-path/(.*)/(.*)/(.*)$ /property/view?ref=$3 [B,R=301,L] # or is it as an encoded string RewriteRule ^some-path/(.*)%2F(.*)/(.*)$ /property/view?ref=$3 [B,R=301,L] # or even double encoded RewriteRule ^some-path/(.*)%252F(.*)/(.*)$

.htaccess AuthUserFile variable based on environment

天大地大妈咪最大 提交于 2020-05-15 09:34:09
问题 I'm trying to load the .htpasswd file based on environment. If I hard code the URL it works fine. AuthType Basic AuthName "Password Protected" AuthUserFile /var/www/html/sitename.dev/docroot/.htpasswd Require valid-user Our hosting provider is providing a global variable you can use in htaccess. %{ENV:AH_SITE_ENVIRONMENT} The Acquia hosting environment — possible values are dev , test , or prod Using the variable we can check on which environment we currently are. If needed it can also be

Apache proxypass does not resolve url for resources like images and css

拥有回忆 提交于 2020-05-15 04:37:07
问题 I need to map a path to my tomcat web application. I used proxypass for this. this is the current config in apache2 <VirtualHost *:80> ServerName localhost:80 ProxyPass /app http://localhost:8088/ui/ ProxyPassReverse /app http://localhost:8088/ui/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> This gets the HTML from tomcat but the css url formed is wrong. Instead of http://localhost/app/css/style.css the url is mapped as http://localhost

Apache proxypass does not resolve url for resources like images and css

点点圈 提交于 2020-05-15 04:37:05
问题 I need to map a path to my tomcat web application. I used proxypass for this. this is the current config in apache2 <VirtualHost *:80> ServerName localhost:80 ProxyPass /app http://localhost:8088/ui/ ProxyPassReverse /app http://localhost:8088/ui/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> This gets the HTML from tomcat but the css url formed is wrong. Instead of http://localhost/app/css/style.css the url is mapped as http://localhost

.htaccess - Make a directory invisible

可紊 提交于 2020-05-08 18:58:10
问题 I have a .htaccess file that currently looks like: <Files .htaccess> order allow,deny deny from all </Files> Options All -Indexes IndexIgnore * # Respond to /include/ with 404 instead of 403 RewriteEngine On RedirectMatch 404 ^/include(/?|/.*)$ I'm trying to prevent everyone from knowing that /include/ exists, however I've come across an issue. Although visiting http://www.example.com/include gives a 404, the browser adds an end slash (thus giving http://www.example.com/include/) which shows

Rewrite requests to directory with htaccess to 404 error

纵饮孤独 提交于 2020-04-18 00:51:40
问题 I would like to rewrite requests to directory secret (http://example.com/secret) with .htaccess file to show always 404 Not Found error. I'm using Apache 2.4. It should work for those cases: /secret/treasure.php (all files and directories in that folder) /secret /secret/ /secret?42 /secret/?23 /secret/.php → should result in 404 Not Found /secret/.htaccess → should result in 404 Not Found My .htaccess rules block everything except the last two cases (I'm getting 403 error, but it should be

Rewrite requests to directory with htaccess to 404 error

白昼怎懂夜的黑 提交于 2020-04-18 00:49:10
问题 I would like to rewrite requests to directory secret (http://example.com/secret) with .htaccess file to show always 404 Not Found error. I'm using Apache 2.4. It should work for those cases: /secret/treasure.php (all files and directories in that folder) /secret /secret/ /secret?42 /secret/?23 /secret/.php → should result in 404 Not Found /secret/.htaccess → should result in 404 Not Found My .htaccess rules block everything except the last two cases (I'm getting 403 error, but it should be

htaccess rewrite rules to remove multiple subfolders from a URL

半腔热情 提交于 2020-03-23 02:07:27
问题 Due file system sub-directory constraints I will most likely reach I want to separate the /users folder into /users/a/username , /users/b/username , /users/c/username , etc. So the data on the server for a user would be in: www.domain.com/users/a/username/ , www.domain.com/users/b/username /, etc I want the URL to be: www.domain.com/users/username/ Optionally to avoid duplicate content a 301 redirect from www.domain.com/users/a/username/ to www.domain.com/users/username/ would also be good.