mod-rewrite

Apache / mod_rewrite / Periods messing with pattern

冷暖自知 提交于 2020-01-05 08:05:11
问题 First question, here goes nothing... I'm trying to add a new entry to my .htaccess file (Apache server) with the hopes of translating this URL: http://platform.localhost/category.all into this URL: http://platform.localhost/index.php?page=category.all The RewriteRule that I'm currently using is this: RewriteRule ^([^/\.]+)\/?$ index.php?page=$1 This rule has worked fine for all URLs up until now, I can only assume that it is the period that is breaking it. What I'm trying to achieve is having

.htaccess redirect URL to specific pattern

大兔子大兔子 提交于 2020-01-05 08:03:13
问题 Supposing I have some URLs, looking like this: site.com/html/photographers-4.cfm?county=test1 site.com/html/photographers-5.cfm?county=test2&speciality=test3 site.com/html/photographers-9.cfm?address4=test4&county=test5 site.com/html/photographers-10.cfm?county=test6&speciality=test7&address4=test8 where testX (...) may be the same or may differ. How would I be able to rewrite each of these so that the URL will be more eye-catching ? site.com/test1-photographers site.com/test2-tes33

Redirect subfolder to root domain

北城余情 提交于 2020-01-05 07:33:32
问题 I want to redirect the subfolder and allcontents to root domain. For example: http://www.example.com/ubb/ will redirect to http://www.example.com I put the .htaccess on ubb folder and the code is: RewriteEngine On RewriteRule ^.*$ / [R=302,L] However when you access http://www.example.com/ubb/threads.php it will redirect to http://www.example.com/threads.php it should be http://www.example.com Is there any code to try or other possible solution? 回答1: Place this rule in /ubb/.htaccess :

Cannot make Relative Path, Rewrite Rules and Routes behave the way I intended

三世轮回 提交于 2020-01-05 05:56:05
问题 Background I am writing a web project with PHP without framework. I used various packages to write in MVC pattern. For the routing part (I used League/Route), I have to set some rewriting rules on Apache server for the routes to work. The company's server is set up in a way that all application codes sit outside of the document root, and alias is used to internally redirect to the application. This leads to a lot of trouble in terms of relative paths, routes and URL rewriting. I'm going to

How do I get .htaccess to redirect from wildcard subdomain page to wildcard subdomain folder

荒凉一梦 提交于 2020-01-05 05:47:08
问题 I want to redirect http://*.domain.co.uk/services.php to http://*.domain.co.uk/services where * is a wildcard domain. Ideally, htaccess should read the services page (as I have more than one) and redirect to the same services folder. This is because I have changed my PHP pages to folder/index.php . 回答1: Add this to the htaccess file in your document root(s): RedirectMatch 301 ^/([^/]+)\.php$ /$1/ You'll most likely need that trailing slash because if it's redirecting you to a directory, mod

Conditional “OR” operation in RewriteRule

纵饮孤独 提交于 2020-01-05 05:39:50
问题 I want to redirect certain urls of my old website to the new website. This redirection to new website is conditional i.e if query param contains key "site" with value as "eu", "jp" or "in" then only redirect otherwise do not. RewriteCond %{QUERY_STRING} (?:^|&)site=(eu) [NC,OR] RewriteCond %{QUERY_STRING} (?:^|&)site=(in) [NC,OR] RewriteCond %{QUERY_STRING} (?:^|&)site=(jp) [NC] RewriteRule ^/?fetchHomePage.action$ https://example.com/%1? [R=301,L,NC] RewriteRule ^/?fetchFirstPage.action$

.htaccess redirect both naked http and https to www https

◇◆丶佛笑我妖孽 提交于 2020-01-05 05:31:09
问题 I have similar issue on one of my domains. I have SSL cert installed both for naked and www-domain. Now, however I want to redirect both naked http://domain.com and https://domain.com to https://www.domain.com. I have this rules in my .htaccess, but it covers redirect when you visit site explicitly with https://domain.com, but, when visiting http://domain.com, it redirects to http://www.domain.com instead https://www.domain.com. RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ RewriteCond %{HTTPS}s

mod_rewrite doesnt work if file with same name as argument exists

时间秒杀一切 提交于 2020-01-05 05:25:27
问题 I'm experiencing some issues with mod_rewrite in htaccess. Let's for instance say I request example.com/foo/, it works perfectly if I don't have a file starting with "foo.*" in the root directory. Let's say I have news.php, sitemape.xml, style.css in root, I can't use /news/ or /sitemap/ or /style/ , it will give a 404 like /news.php/ etc. Here's my rewrite string. It works locally with my Apache 2.2.22 but not at my web-host with the same Apache version. RewriteRule ^([A-Za-z0-9]+)/?$ index

Adding more directories to url using mod_rewrite

Deadly 提交于 2020-01-05 04:51:34
问题 I am using mod_write to pull urls out of my database. I have it working at a basic level, but what I am stuck on is creating complex URLs using various slugs pulled from the database as directories in the URL. Currently the url before using mod_rewrite looks like: www.domainname.co.uk/company?=1&staff=3 Which takes you to a staff profile within an appropriately styled company page. But what I want the URL to look like is: www.domainname.co.uk/COMPANY-NAME/STAFF-NAME My htaccess currently

.htaccess 403 Forbidden if url contains directory with another htaccess file

情到浓时终转凉″ 提交于 2020-01-05 04:37:11
问题 I have a .htaccess file in website root with the following rules : Options -MultiViews Options All -Indexes RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA] And another .htaccess file in a sub-directory (let's call it Foo ) : Order Allow,Deny Deny from all <files ~ "\.(js|jpe?g|png|gif|bmp|css)"> Allow from all </files> When I access for example : /test/test/test it normally redirects me to index.php , but when I my URI starts with existing