apache,.htaccess,mod-rewrite,nginx
First of all, you have to understand what this .htaccess do. Except of incomplete rewrite this .htaccess tries to serve precompressed assets (file.css.gz instead of file.css) and rewrites requests for non-existent files to index.php. I would write something like this: location / { try_files $uri $uri/ /index.php; } location ^~...
Try this instead: RewriteEngine On RewriteRule ^$ /welcome [R=302,L] RewriteRule ^welcome$ /index.html [L] First line redirects a request made to the root to /welcome. Second rule internally rewrites /welcome to index.html....
regex,apache,.htaccess,mod-rewrite
Try this code in root .htaccess: Options +FollowSymLinks -MultiViews RewriteEngine On # to convert spaces to hyphens RewriteRule "^(pdf)/(\S*) +(.*)$" /$1/$2-$3 [L,NE,R=302] RewriteRule ^(pdf/.+)$ /pdf.php?file=$1 [L,QSA,B,NC] ...
php,apache,.htaccess,mod-rewrite
Seems register_globals is the issue. http://php.net/manual/en/security.globals.php Add following line at the top: $id = $_GET['id']; ...
php,apache,.htaccess,mod-rewrite
What I mean by prepend, is use a name so that it will match the rule specifically. Like the word shop. Something like this. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^shop/([^/]+)/([^/]+)/([^/]+)\.php$ /shop.php?id_cat=$1&id=$2&subcat=$3 [L] Then you can use a URL like this and it won't interfere with your...
php,apache,.htaccess,mod-rewrite
You need to redirect the trailing slash URL's instead of just rewriting them. You also probably need to add some conditions to the rules: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)$ /includes/category.php?url=$1&pageType=category [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond...
i'm sure this is a duplicate but here the code i use: RewriteEngine on #This removes the www. RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [L,R=301,NC,QSA] #This makes redirect to https RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] ...
You can use this rule in your /user/projects/.htaccess. RewriteEngine On RewriteBase /user/projects RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([0-9]+)/?$ index.php?project_id=$1 [NC,L] From the root you can do. RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /+user/projects/index\.php\?project_id=([^&\ ]) RewriteRule ^ %1? [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^user/projects/([0-9]+)/?$...
php,regex,apache,.htaccess,mod-rewrite
You need to place this line on top of your .htaccess to turn off MultiViews option: Options -MultiViews Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php....
regex,apache,.htaccess,mod-rewrite
You can use a new rule for underscore condition: RewriteEngine on RewriteRule ^en-gb/([^/]+)/([^/.]+)/?$ /site/views/en/gb/$1_$2.html [L,NC] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteCond %{DOCUMENT_ROOT}/$1\.html -f RewriteRule ^(.+?)/?$ $1.html [L] RewriteCond %{DOCUMENT_ROOT}/$1\.php -f RewriteRule ^(.+?)/?$ $1.php [L] RewriteRule ^en-gb(.*)$ /site/views/en/gb/$1 [L,NC] ...
php,apache,.htaccess,mod-rewrite,url-rewriting
You can use this code in your /myproject/.htaccess file: RewriteEngine On RewriteBase /myproject/ RewriteCond %{QUERY_STRING} ^supplier=([^&]+) [NC] RewriteRule ^/?$ ?product_cat=%1 [L,R=301] ...
regex,apache,.htaccess,mod-rewrite,redirect
Try this rule instead: RewriteCond %{HTTP_HOST} ^sub\.example\.com$ [NC] RewriteCond %{THE_REQUEST} !\s/+(aaa|bbb|ccc)/ [NC] RewriteRule . http://www.example.com%{REQUEST_URI} [R=301,L,NE] Test it after clearing your browser cache. Using THE_REQUEST instead of REQUEST_URI to make sure we use unchanged URI values as received by Apache....
apache,.htaccess,mod-rewrite,cookies,url-rewriting
Try this : RewriteEngine On #Redirecting with the cookie value RewriteCond %{HTTP_COOKIE} ^lang=(en|es)$ [NC] RewriteRule ^(.*)$ http://example.com/%1/$1 [R,L] If the cookie is set to "en" this will redirect every requests to example.com/en/...
php,apache,.htaccess,mod-rewrite,friendly-url
You can have a new rule for that: RewriteEngine On RewriteBase /app/ RewriteRule ^([a-z]+)/([a-z]+)/?([0-9]*)$ index.phpcontroller=$1&action=$2&id=$3 [NC,L,QSA] # If the request is not for a valid directory RewriteCond %{REQUEST_FILENAME} !-d # If the request is not for a valid file RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] ...
apache,.htaccess,mod-rewrite,redirect,https
# HTTPS page Redirects RewriteEngine On # This will enable the Rewrite capabilities RewriteCond %{HTTPS} !=on # This checks to make sure the connection is not already HTTPS RewriteRule ^/?enrolments/(.*) https://%{SERVER_NAME}/enrolments/$1 [R,L] #END https redirects ...
regex,apache,.htaccess,mod-rewrite
You can use this rule: RewriteCond %{HTTP_HOST} ^[^.]+\.com(\.au)?$ [NC] RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L] ...
regex,apache,.htaccess,mod-rewrite
You can tweak your rules like this: RewriteEngine On RewriteBase /core/ #Check if file exist in original path (/var/www/html/core): RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] #try new path (/var/www/html/core/latest): RewriteCond %{DOCUMENT_ROOT}/core/latest/$1 -f RewriteRule ^((?!latest/).*)$ latest/$1 [L,NC] RewriteCond %{DOCUMENT_ROOT}/core/latest/$1 -f makes sure...
apache,http,mod-rewrite,ssl,url-rewriting
You should add another RewriteCond to exclude redirect for this IP: RewriteCond %{SERVER_PORT} =80 RewriteCond %{REMOTE_ADDR} !=10.1.2.3 RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [R,L] ...
It may help: RewriteRule ^(apple|orange)/$ /product.php?prod=$1 [L]...
.htaccess,mod-rewrite,redirect
Add question sign after to remove query string RewriteRule ^news/news\.php$ /posts/vanity-url.php? [L,R=301] ...
You can use this in your .htaccess to do the reverse. RewriteEngine On RewriteCond %{THE_REQUEST} [A-Z]{3,}\ /product\.cgi\?id=([^&\ ]+) RewriteRule ^ /id/%1? [R=301,L] RewriteRule ^id/([^/]*)$ /product.cgi?id=$1 [L] ...
php,apache,.htaccess,mod-rewrite,redirect
Try this in your root .htaccess: Options +FollowSymlinks -MultiViews RewriteEngine on RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^post/(.+)$ post.php?tag=$1 [L,NC,QSA] RewriteRule ^search/(.+)$ search.php?tag=$1 [L,NC,QSA] ...
php,apache,.htaccess,mod-rewrite,url-rewriting
You can replace your rule by this rule: RewriteRule ^(spashop)/admin/([a-zA-Z]+)/?$ $1/index.php?url=spaAdminShop/$2\?%{QUERY_STRING} [L,NC] ...
If there was no query string involved, RedirectMatch could be used (not sure why it was made to ignore that part of URLs, or maybe I am mistaken). Anyway, with mod_rewrite try this: RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^/ar/idea\.php\?permalink=(.*?)$ RewriteRule . /ar/%1? [R=301] This is assuming there is a RewriteEngine On directive present,...
regex,apache,.htaccess,mod-rewrite,redirect
There might be other rules in your .htaccess changing REQUEST_URI to something else and causing negation based condition to pass. Try this instead: RewriteCond %{THE_REQUEST} !/categoryOne RewriteRule ^ http://www.google.be/ [L,R=301] THE_REQUEST variable doesn't change its value after other rules....
apache,.htaccess,mod-rewrite,url-rewriting
The first RewriteRule never will be used because of RewriteCond. It always false. %{REQUEST_FILENAME} return full path on server, no filename. The second rule alone makes infinite loop redirecting /site/index.php to itself. If you explain what you want, we try to help youto make working htaccess UPDATE RewriteEngine on #...
apache,.htaccess,mod-rewrite,url-rewriting
You can use a negative lookahead to exclude the subdirectory, like so: RedirectMatch 404 /directory(?!/sub/sub/sub/sub) You'll also notice that I've removed the check for the trailing slash or end of string. Reason being: directories always have trailing slash (unless DirectorySlash is set to off). Also, no need to check for...
ajax,.htaccess,mod-rewrite,seo
This is how I rewrote it so that all ?_escaped_fragment_=/XXXXX requests got redirected to /XXXXX without the query RewriteCond %{QUERY_STRING} ^_escaped_fragment_=(.*)$ RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%1? [L,R=301] This makes www.domain.com/?_escaped_fragment_=/somepage redirect (permanently) to www.domain.com/somepage ...which is just what I wanted....
php,apache,.htaccess,mod-rewrite
This is what you need to do. You can use this code in your .htaccess. RewriteEngine On RewriteBase /testwebsite/ #redirect index.php to the pretty URL RewriteCond %{THE_REQUEST} [A-Z]{3,}\ /testwebsite/index\.php RewriteRule ^ home? [R=301,L] #internally rewrite pretty URL to index file RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^home/?$ index.php [L]...
You can use the following instead: RewriteEngine on # Check that the file exists RewriteCond %{REQUEST_FILENAME} -f # Check we're not being referred from our own domain RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?my-site\.com [NC] # Check that the request is not fot the hotlink image RewriteCond %{REQUEST_URI} !^/images/dontsteal\.png$ [NC] # If all the...
php,apache,.htaccess,mod-rewrite
Try this: Options -MultiViews RewriteEngine On #Working rules: RewriteRule ^privacy$ privacy.php [L] RewriteRule ^terms$ terms.php [L] RewriteRule ^team$ team.php [L] RewriteRule ^candidates$ candidates.php [L] RewriteRule ^clients$ clients.php [L] RewriteRule ^article/([^/]+)/?$ article.php?id=$1 [L,QSA] RewriteRule ^job/([^/]+)/?$ job.php?id=$1 [L,QSA] RewriteRule ^contact/([^/]+)/?$ contact.php?location=$1 [L,QSA] Option MultiViews is used by Apache's content negotiation module that...
apache,.htaccess,mod-rewrite,redirect
Why not just exclude the new site, if I am understanding correctly? RewriteEngine On RewriteCond %{HTTP_HOST} !^(www\.)?newsite\.com [NC] RewriteCond %{HTTP_HOST} ^www\.oldsite\.com [NC] RewriteRule ^(.*)$ https://oldsite.com/$1 [R=301,NE,L] RewriteCond %{HTTPS} ^off RewriteCond %{HTTP_HOST} !^(www\.)?newsite\.com [NC] RewriteRule ^(.*) https://oldsite.com/$1 [R=301,NE,L] Alternatively maybe you can just tell it to not do anything based on...
mod-rewrite,unity3d,swf,swfobject
I did some further tests, sadly there are no errors on the console. But it pretty much looks like there's something wrong with your .swf file on the server, because when I download the file from your server it is not working locally either. (Did you try that before?) How...
As it turns out, the statement "latter rule is always matched & the former is never matched" may not have been true; I had a confusing httpd.conf in which rewrite logging was enabled in more than one place. In any event, the first rule was definitely incomplete. It should look...
php,regex,.htaccess,mod-rewrite,http-status-code-301
To create exception for administrator folder you can do: RewriteRule ^(?!administrator/).+?(index\.php)$ /$1 [L,NC,R=301] ...
apache,.htaccess,mod-rewrite,url-rewriting,rewrite
You can use this code in your /subfolder/search-brands/.htaccess file: RewriteEngine On RewriteBase /subfolder/search-brands/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+)/?$ index.php?q=$1&brand=$2 [L,QSA] ...
So you want the assets to be requested correctly? I guess you're using incorrect relative paths for linking those in your page's code (something like "images/image.jpg"..). If that's the folder structure you have, try to go one level up and use this path: <img src="../admin/images/image.jpg" ... or, in the case...
php,.htaccess,mod-rewrite,redirect
Try this : RewriteEngine On RewriteCond %{QUERY_STRING} ^s=([^&]+)&type=([^&]+) [NC] RewriteRule ^data.php$ /d.php?s=%1&t=%2 [NC,R,L] This will externally redirect a request for : /data.php?s=foo&type=bar to /d.php?s=foo&t=bar ...
regex,apache,.htaccess,mod-rewrite,url-rewriting
Change your rules like this: RewriteEngine On RewriteCond %{HTTP_HOST} ^(purchase|booking)\.mydomain\.com$ RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L] RewriteCond %{HTTP_HOST} =purchase.mydomain.com RewriteRule ^((?!purchase/).*)$ /purchase/$1 [L] RewriteCond %{HTTP_HOST} =booking.mydomain.com RewriteRule ^((?!booking/).*)$ /booking/$1 [L] http:// or https:// in target will redirect instead of rewriting. ...
regex,apache,.htaccess,mod-rewrite,litespeed
Unfortunately, LiteSpeed does not support SetEnvIf* directives in .htaccess files. As an alternative, you'll need to use mod_rewrite: RewriteEngine On # Check that the request is for /bg.js RewriteCond %{REQUEST_URI} ^/bg.js # Check that the request matches an existing file RewriteCond %{REQUEST_FILENAME} -f # Check that the user agent does...
php,.htaccess,laravel,mod-rewrite
Set a RewriteBase for the new folder, like so: RewriteEngine On RewriteBase /site1/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] ...
php,apache,.htaccess,mod-rewrite
Well for this specific example. example.com/xxx/en i need index.php?lang=en&a=xxx You can use a rule like this. RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/en/?$ /index.php?lang=en&a=$1 [L,QSA] ...
regex,apache,.htaccess,mod-rewrite
You can use these rules: <IfModule mod_rewrite.c> RewriteEngine on # block these URIs RewriteRule (register|login) - [F,NC] RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] </IfModule> ...
php,apache,codeigniter,mod-rewrite
Remove this and try again: <IfModule authz_core_module> Require all denied </IfModule> <IfModule !authz_core_module> Deny from all </IfModule> ...
php,regex,.htaccess,mod-rewrite,redirect
Try these rules: RewriteRule ^login/?$ ?i=l [L,QSA] RewriteRule ^login(&[^/]+)/?$ ?i=l$1 [L,NC] Though I suggest using: domain.com/login?redirect=/account/settings and get rid of 2nd rule altogether. QSA flag in first rule will add redirect=/account/settings query parameter as $_GET to your php file....
Try the following rules in your /htaccess file : RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/([^.-]+)\.php [NC] RewriteRule ^ %1/ [NC,R,L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/([^-]+)-([^.]+)\.php [NC] RewriteRule ^ %1/%2/ [NC,R,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/?$ $1.php [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/?$ $1-$2.php [QSA,NC,L] ...
regex,apache,.htaccess,mod-rewrite
You can use this code in your DOCUMENT_ROOT/.htaccess file: RewriteEngine On RewriteCond %{QUERY_STRING} (^|&)m=1(&|$) [NC] RewriteRule ^ %{REQUEST_URI}? [L,R=302] (^|&)m=1(&|$) regex is to make sure m=1 is matched anywhere in query string....
php,regex,apache,.htaccess,mod-rewrite
That is because your use of [^-] in your regex. Use this code: ErrorDocument 404 /404.php ErrorDocument 403 /403.php Options -indexes RewriteEngine on RewriteCond %{HTTP_HOST} ^example\.com RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f RewriteRule ^(.*)$ $1.php [L] RewriteRule ^products/([^/]+)/([^/]+)/([^/]*)$ /products.php?produucts_name=$1&products_des=$2&products_id=$3 [L] ...
regex,apache,.htaccess,mod-rewrite,url-rewriting
Use this rule in /subfolder/.htaccess: RewriteEngine on RewriteBase /subfolder/ RewriteRule ^([^/]+)/([^/]+)\.html$ index.php?a=$1&u=$2 [L,QSA,NC] ...
php,css,apache,.htaccess,mod-rewrite
But book.php file includes the CSS and JS files as www.domain.com/city/css and www.domain.com/city/js and hence comes up with the error 404. That I believe is due to your use of relative paths in including css and js files. For that you can add this in the <head> section of...
php,apache,.htaccess,mod-rewrite,url-rewriting
QUERY_STRING is only used to match query string without URI. You need to use: Options -MultiViews RewriteEngine On RewriteBase /mywbsite/ RewriteCond %{THE_REQUEST} /search_data\.php\?keywords=([^&]+)&f=([^\s&]+) [NC] RewriteRule ^ search/%1/%2? [R=301,L] RewriteRule ^search/([^/]+)/([^/]+)/?$ search_data.php?keywords=$1&f=$2 [QSA,L,NC] ...
apache,mod-rewrite,virtualhost
This rule should work for you RewriteEngine on RewriteCond %{HTTP_HOST} =abc RewriteRule ^(.*)$ http://abc.xyz.com/$1 [R,L] ...
php,apache,.htaccess,mod-rewrite,redirect
From the mod_alias/Redirect documentation: Additional path information beyond the matched URL-Path will be appended to the target URL. "Additional path information" is somewhat vague, but I assume they are referring to the url parameter. Now, this should not affect functionality at all, so again I assume that you just don't...
.htaccess,mod-rewrite,redirect,url-rewriting,file-extension
You can use: RewriteEngine On RewriteCond %{THE_REQUEST} /index [NC] RewriteRule ^(.*?)index(?:\.html)?$ /$1 [L,R=301,NC] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*)/index$ $1/ [R=301,L,NC] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+?)/$ $1 [R=301,L] ...
regex,apache,.htaccess,mod-rewrite
First of all a very good question with lots of details. If you enable RewriteLog you will notice this is actually being caused by this line (when you request http://localhost/h/first/second URL): add path info postfix: /landingpage1.php/second There a bug raised specifically for this issue on Apache.org. This happens when you...
regex,apache,.htaccess,mod-rewrite
Keep your first rule as: RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC] RewriteCond %{THE_REQUEST} !/googleverification\.html [NC] RewriteRule ^ http://www.newdomain.com%{REQUEST_URI} [L,R=301,NE] ...
.htaccess,mod-rewrite,url-rewriting,rewrite,file-extension
Unfortunately, this is not possible. The TestString part of RewriteCond can only contain a plain string, and allows for server variables (HTTP_REFERER, for example) and back-references ($1 and %1, for example). As such, you cannot include an expression in the TestString - only the CondPattern (the second part of RewriteCond)...
You need an OR condition here: RewriteEngine on RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^ https://www.domain.com%{REQUEST_URI} [R=301,L,NE] ...
php,apache,.htaccess,mod-rewrite,url-rewriting
This should work. Try your rules this way. It works for me. Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^catelogue/([^/]+)/([^/]+)$ catelogue.php?page=3&cat1=$1&cat2=$2 [NC,L] RewriteRule ^catelogue/?$ catelogue.php?page=3 [NC,L] RewriteRule ^home/?$ index.php?page=1 [NC,L] ...
I don't think it will work, it will ask for the authorization before the redirect to SSL. Instead you could put the Auth directives in a VirtualHost block corresponding to the SSL port (443). Also you don't really need mod_rewrite, but a simple Redirect directive. <VirtualHost *:80> ServerName www.domain.com Redirect...
php,apache,.htaccess,codeigniter,mod-rewrite
I think the problem are the missing placeholders. Without the placeholders your stated URL http://www.mysite.pk/jobs/search/faisalabad/all-cats won't match. The correct route should look like this: $route["jobs/pakistan/(:any)"]="vacancies/search"; $route["search/pakistan/(:any)"]="vacancies/search"; This way both jobs/pakistan and search/pakistan are working. Edit This RewriteRule will have the same effect when put in the .htaccess file. RewriteRule ^jobs/search/(.*)?$...
php,apache,.htaccess,mod-rewrite
You can use this rule in /gt/.htaccess: Options +FollowSymlinks RewriteEngine On RewriteBase /gt/ RewriteRule ^/?$ gt.php [L] ...
You can't match against the query string (everything after the ?) in a rewrite rule, you need to match against the %{QUERY_STRING} variable in a condition: RewriteCond %{QUERY_STRING} ^page=11\.$ RewriteRule ^index\.php$ /index.php?page=11 [L,R=301] ...
php,apache,.htaccess,mod-rewrite
Oddly enough /new/home/ works but any other like /new/contact-us/ does not work. The only thing I can think of is /home/ is the only one without a '-' character in the url. Am I missing something in my .htaccess to account for this? You are absolutely missing something to...
You can change your PHP code like this: $name = filter_input(INPUT_GET, 'name'); if ($result = $mysqli->query("SELECT * FROM pages WHERE name='$name'")) { if ( $result->num_rows == 0 ) { printf('404 / page Not Found'); exit; } else { while ($row = $result->fetch_assoc()) { echo $row['content']; } } } else {...
regex,wordpress,.htaccess,mod-rewrite,redirect
The way you are trying to capture substrings and inject them into the substitution string is totally wrong. Try this: RewriteRule ^([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/(\d*)/?$ http://localhost/ats-new/$1/$2-$3 [R=301,NC,L] ...
? is part of QUERY_STRING and not REQUEST_URI, and so you cannot check it directly in the rule itself. You can check for the presence of the ? by checking either QUERY_STRING or THE_REQUEST: # Check that QUERY_STRING is not empty: RewriteCond %{QUERY_STRING} !^$ RewriteRule ^ http://google.com/ [P] # Check...
Try : RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/?directory-1/productorder\?i=([^&\s]+) [NC] RewriteRule ^ /directory2/%1? [NE,NC,R,L] Your rewriterule is not working because of the following reasons : 1) A leading slash in RewriteRule directive is not required if you are using apache version 2. 2) Query string is not a part of match in...
regex,apache,.htaccess,mod-rewrite,url-rewriting
You will need an additional router rule to forward all non-file and non-directories to index.php with a parameter p: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] # If the request is not for a valid directory RewriteCond %{REQUEST_FILENAME} !-d # If the request is not...
php,regex,apache,.htaccess,mod-rewrite
You can add a new rule for +/- conversion: Options -MultiViews RewriteEngine On RewriteBase /indianrealitybytes/ RewriteCond %{THE_REQUEST} /search_advance\.php\?keywords=([^&]+)&f=([^\s&]+) [NC] RewriteRule ^ search/%1/%2? [R=301,L] RewriteRule ^([^+]*)\+(.*)$ $1-$2 [R=302,NE,L] RewriteRule ^search/([^/]+)/([^/]+)/?$ search_advance.php?keywords=$1&f=$2 [QSA,L,NC] ...
apache,.htaccess,mod-rewrite,redirect,rewrite
You can use this code in your DOCUMENT_ROOT/.htaccess file: Options -Indexes +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{THE_REQUEST} !/search/ [NC] RewriteRule ^(.*)$ search/$1 [L,R] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f <IfModule mod_php5.c> RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>...
I would use this rule: RewriteRule ^(.*)\/(.*)-(\d{4})(?:-(.*))?$ album.php?artist=$1&album=$2&releaseyear=$3&EXTRA=$4 Try it...
apache,.htaccess,mod-rewrite,redirect
This should work in your .htaccess file on example.com. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/?$ http://example2.com/$1 [R=302,L] Change to R=301 when you confirm it's working. ...
regex,apache,.htaccess,mod-rewrite,url-rewriting
Create /blog/.htaccess if it doesn't already exist and place this rule: RewriteEngine On RewriteBase /blog/ RewriteRule ^/?$ blog.html [L] # To internally forward /blog/file to /blog/file.html RewriteCond %{DOCUMENT_ROOT}/blog/$1\.html -f [NC] RewriteRule ^(.+?)/?$ $1.html [L] ...
php,regex,apache,.htaccess,mod-rewrite
You can do: <ifModule mod_rewrite.c> # Turn on the engine: RewriteEngine on # Redirect certain paths to index.php: RewriteRule ^(search|contact)/?$ index.php?p=$1 [L,QSA,NC] RewriteRule ^([\w-]+)/([\w-]+)/?$ index.php?p=$1&user=$2 [L,QSA,NC] </ifModule> ...
apache,.htaccess,mod-rewrite,redirect
I'm assuming that you are trying to do two things here: Force HTTPS and www. Redirect to test.php if a certain IP is making the request The issue you were facing was due to the fact that even though the IP address was being matched, it was still being checked...
php,regex,apache,.htaccess,mod-rewrite
You can tweak your regex like this: RewriteRule orderprod_cntr/([^/]+)/([^/]+)/?$ controller/orderprod_cntr.php?id1=$1&id2=$2 [L,QSA] ...
php,apache,.htaccess,mod-rewrite,redirect
I have resolved my problem migrating my "spaghetti code" to a Laravel framework, and using the file routes.php to pass the variables and blade templates for minimizing the use of this variables.
php,.htaccess,mod-rewrite,redirect
Just use this. Replace example.com with your domain. RewriteEngine on RewriteCond %{HTTP_HOST} ^example\.com [NC,OR] RewriteCond %{HTTPS} !^on RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L] ...
Your rule is backwards - it works the other way around. You can try with the following: RewriteRule ^folder1/folder2/(.*)$ /demo/folder1/$1 [R,L] Or perhaps you'd like to make folder1 dynamic: RewriteRule ^([^/]+)/folder2/(.*)$ /demo/$1/$2 [R,L] If one of these works for you, and you would like to make the redirect permanent, you...
.htaccess,mod-rewrite,http-status-code-301
You need to add a grouping in your regex and backreference in the redirect: RewriteEngine On RewriteCond %{HTTP_HOST} (^|\.)sub\.domain1\.com$ [NC] RewriteRule ^somefolder/(.*)$ https://domain2.com/$1 [R=301,L] And you don't need the condition to check the request URI, since you're already doing that in the rule's regex....
regex,apache,.htaccess,mod-rewrite,redirect
You can use an OR condition in conditions: Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^www\. [NC,OR] RewriteCond %{THE_REQUEST} /subdir/ [NC] RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^(?:subdir/)?(.*)$ http://%1/$1 [NC,R=302,L] ...
php,regex,.htaccess,mod-rewrite
You are already passing it, but just don't use $_GET. Try this. RewriteEngine on RewriteRule . /process.php [L,NE] Then in PHP print_r($_SERVER["REQUEST_URI"]); Then you can explode on /....
apache,.htaccess,mod-rewrite,redirect
You need a new rule for that redirect: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} /(?:index\.php)?\?search=([^\s&]+) [NC] RewriteRule ^ search/%1? [R=302,L,NE] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^search/(.*)$ /?search=$1 [L,QSA] ...
apache,.htaccess,mod-rewrite,https
You need to tell the RewriteCond what to match !/go/ against. Change the second line to: RewriteCond %{REQUEST_URI} !/go/ [NC] ...
php,apache,.htaccess,mod-rewrite
RewriteRule does not accept query. Use RewriteCond RewriteEngine on RewriteCond %{QUERY_STRING} (\w.+)-(\w.+) RewriteRule ^pass/$ view/pass.php?useremail=%1&actcode=%2 [L] ...
The problem is that the RewriteRule assumes root is the location of .htaccess, not the current folder. The following code solves my question. RewriteOptions inherit RewriteEngine On RewriteRule /?$ example.php This post helped me: .htaccess RewriteRule not working in subdirectory...
.htaccess,mod-rewrite,redirect,http-status-code-301,http-redirect
You can get rid of all the code in your .htaccess and use this rule instead: RewriteEngine on RewriteRule ^ http://siteTWO.co.uk/? [R=301,L,NE] Make sure to clear your browser cache before testing this....
php,apache,.htaccess,mod-rewrite
As mention in my comment, it will work if you shuffle your rules from bottom to top. Possible reason could be conflicting rules. So your .htaccess should look like, RewriteEngine On RewriteRule ^privacy/?$ privacy.php [L] RewriteRule ^terms/?$ terms.php [L] RewriteRule ^login/?$ loginregister.php [L] RewriteRule ^register/?$ loginregister.php [L] RewriteRule ^member/([^/]*)$ member.php?id=$1...
php,apache,.htaccess,mod-rewrite,url-rewriting
1st and 2nd rule cannot coexist because they are matching same URI pattern. Only first will all the time. Tweak your rules like this: RewriteEngine on RewriteRule ^(shows)/([a-z_-]+)/?$ index.php?switch=$1&shows=$2 [NC,L,QSA] RewriteRule ^(news)/([a-z_-]+)/?$ index.php?switch=$1&article=$2 [NC,L,QSA] RewriteRule ^(shows|news|articles)/?$ index.php?switch=$1 [NC,L,QSA] ...
regex,apache,.htaccess,mod-rewrite,rewriting
I suggest not using .php in pretty URL, make it extension-less. Try these rules in v2/.htaccess: RewriteEngine On RewriteBase /v2/ RewriteCond %{THE_REQUEST} /message\.php\?ID2=([^&\s]+) [NC] RewriteRule ^ message-%1? [NE,R=302,L] RewriteRule ^message-(.+)/?$ message.php?ID2=$1 [L,QSA,NC] ...
php,wordpress,apache,mod-rewrite,centos7
i found the way to know if a module is loaded or not, here's to command to list the modules enabled: apachectl -M | sort It will list all enabled modules alphabetically. Wordpress has an .htaccess but default where it enables Rewrite_Mod for its use: # BEGIN WordPress <IfModule mod_rewrite.c>...
php,apache,.htaccess,mod-rewrite
Remove space before $ to make it RewriteRule ^.*startAd/(.*)$ /post-ad-step-2.php?adType=$1 [L,QSA] ...
wordpress,apache,.htaccess,mod-rewrite,redirect
Try just: RewriteRule ^&force= / [L,NC,R=301] ...
regex,apache,.htaccess,mod-rewrite,redirect
You can use this code in your DOCUMENT_ROOT/.htaccess file: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{QUERY_STRING} !(^|&)dev=1(&|$) [NC] RewriteRule !^maintenance\.html$ maintenance.html [L,NC] Key is use of query parameter dev=1. Without this query parameter site will show maintenance.html. But if you add ?dev=1 to your URL then you...
You have no choice but to use rewrite for this That's what it's for. But I already have some htaccess rewrites (JOOMLA), and it is just for the only folder.. This absolutely does not matter. Your Apache setup can contain as many rewrites as you need. I've seen 100's. So...
RewriteCond %{REQUEST_FILENAME} !-f makes sure existing files are not rewritten hence images/css/js files won't be routed to index.php. However your problem seems to be use of relative paths for images/css/js. Make sure to use absolute path in your css, js, images files rather than a relative one. Which means you...
Your issue is that the first rule matches, the last one can never get applied... RewriteEngine on RewriteRule ^gallery/([0-9]+)/?$ gallery.php?id=$1 [NC,L] RewriteRule ^([0-9a-zA-Z_-]+)/([0-9]+)$ products.php?cat=$1&id=$2 [NC,L] RewriteRule ^([^/]*)/([0-9a-zA-Z_-]+)/([0-9]+)$ product_categories.php?cat=$2&id=$3 [NC,L] RewriteRule ^(.*)/(.*)/([0-9a-zA-Z_-]+)/([0-9]+)$ product_details.php?cat=$3&id=$4 [NC,L] Rule of thumb: first the specific exceptions, then the more general rules. The NC flag does not...
Remove leading slash from RewriteRule. It doesn't receive it. And doesn't receive Query string. Ifqp is present, QSA will save it. Must be enough: RewriteEngine on RewriteRule ^css/(.*).css$ /build/css.php?request=$1 [QSA] ...