FAQ Database Discussion Community


Make dynamic links (with ?) return error 404 not found

apache,.htaccess,dynamic,hyperlink,http-status-code-404
Using .htaccess (are there any other solutions?) is there a way to make all dynamic links (links containing the sign ?) of a site return a 404 not found response header? For example: http://www.example.com/?bla_bla - will return 404 http://www.example.com/test/index.html?no_redirect=true - will return 404...

Block all user-agents by htaccess except one

regex,apache,.htaccess,mod-rewrite,litespeed
I have a htaccess rewrite rule code which works on Apache but not on litespeed. <Files "bg.js"> SetEnvIfNoCase User-Agent .*autoit.* search_robot Order Deny,Allow Deny from All Allow from env=search_robot </Files> I want to block all useragents except those that are a case insensitive match to autoit. How do I get...

OctoberCMS : Have to go to index.php

php,.htaccess,apache2,octobercms,ovh
On my OctoberCMS website, I always have to navigate through index.php. For example: Go to a page : mywebsite.com/index.php/mypage instead of mywebsite.com/mypage Admin : mywebsite.com/index.php/backend instead of mywebsite.com/backend All the links are cutently to mywebsite.com/linktopage and when I go to mywebsite.com/index.php, all the links switched to mywebsite.com/index.php/linktopage/. Thats weird. Here...

.HTAccess - How to modify a url with under score in file name as sub directory?

regex,apache,.htaccess,mod-rewrite
Lets say I have a directory with the following files: news_sports.html news_food.html news.html index.html How would I make it using .Htaccess so that when my website is being accessed by http://example.com/en-gb/news/sports it get's it out of news_sports.html and http://example.com/en-gb/news/food reads out of news_food.html and http://example.com/en-gb/news (with or without the slash...

How to protect a single php page with htaccess?

php,.htaccess
I want to restrict a PHP page in a website. This page is in a CMS. The page is like this. http://bioenergysciences.com/innerpage.php?id=1 For this I have updated my .htaccess file like this. AuthName "Restricted Area" AuthType Basic AuthUserFile /home/bioenerg/password/.htpasswd AuthGroupFile /dev/null <Files http://bioenergysciences.com/innerpage.php?id=1> require valid-user </Files> Then I created .htpasswd...

Redirect 301 with wordpress articles from a domain to another

wordpress,.htaccess,redirect
my client changed his wordpress website to a new domain. I tried with the htaccess to redirect 301 the articles dynamicaly but it's not working. The URL format of articles are : /%year%/%monthnum%/%day%/%postname%/ I put this in htaccess but not working : redirect 301 /([0-9]*)/([0-9]*)/([0-9]*)/(.*)/ http://www.newdomain.com/$1/$2/$3/$4/ Can you help me...

.htaccess Mod_Rewrite inconsistent

php,apache,.htaccess,mod-rewrite
Here is my .htaccess file: 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] #Not working rules: RewriteRule ^article/([^/]*).*$ article.php?id=$1 [L] RewriteRule ^job/([^/]*).*$ job.php?id=$1 [L] RewriteRule ^contact/([^/]*).*$ contact.php?location=$1 [L] The top rules are all working...

.htaccess rewrite for keeping a trailing variable

.htaccess,mod-rewrite
My .htaccess rewrite attempt is not working. I'd like the request /directory-1/productorder?i=38371 to go to /directory-2/38371 where the number 38371 can vary. My rewrite so far: RewriteEngine On RewriteRule ^/directory1/productorder?i=(.+)$ /directory2/$1 [L] The page is not redirecting with my current implementation....

Remove plus sign from url using .htaccess

php,regex,apache,.htaccess,mod-rewrite
My current url is: http://localhost/mywbsite/search/one+piece/149 I want to change link to like this http://localhost/mywbsite/search/one-piece/149 I have already .htaccess file with this code Options -MultiViews RewriteEngine On RewriteBase /indianrealitybytes/ RewriteCond %{THE_REQUEST} /search_advance\.php\?keywords=([^&]+)&f=([^\s&]+) [NC] RewriteRule ^ search/%1/%2? [R=301,L] RewriteRule ^search/([^/]+)/([^/]+)/?$ search_advance.php?keywords=$1&f=$2 [QSA,L,NC] I don't know where to change to remove plus(+) sign...

How to modrewrite in my subfolder

regex,apache,.htaccess,mod-rewrite,url-rewriting
I have a PHP script on a subfolder of my server and it generates url like this: http://example.com/subfolder//index.php?a=profile&u=username Instead I would like a SEO friendly url like: http://example.com/subfolder/profile/username.html I'm on Apache and mod_rewrite is enabled, so I edited the .htaccess of my subfolder page: RewriteEngine On RewriteRule ^([^/]*)/([^/]*)\.html$ //index.php?a=$1&u=$2 [L]...

Rewriting with .htaccess doesn't work

regex,apache,.htaccess,mod-rewrite
I'm trying to make URL's look better by using a RewriteRule in .htaccess, but it doesn't work. This is the case. I have a root folder in which there is a PHP-file called pdf.php. The script in that file sends a PDF-file to the user, which name is given as...

Redirecting http to https

apache,.htaccess,redirect,ssl,https
I'd like to redirect all of my http traffic to https, currently in my htaccess file I have the following redirecting my http traffic: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] </IfModule> This redirects all of my non-www to www. What is the best way to...

file not found in apache server : PHP

php,.htaccess,apache2
I have below directory structure in PHP application. Last 2 files I can access it. but, when I try to open first 2 files, it says file not found. I checked it all files are there. And same permissions given to all files. I don't know what's wrong in here....

How do I redirect a URL with a parameter to a clean URL in htaccess?

.htaccess,mod-rewrite,redirect
I am attempting to 301 redirect several URLs with parameters at the end to clean URLs. For example I am trying to redirect: http://example.com/news/news.php?id=1234 to http://example.com/posts/vanity-url.php Here is my code: RewriteCond %{QUERY_STRING} id=1234 RewriteRule ^news/news\.php$ /posts/vanity-url.php [L,R=301] I feel like I'm close with this code but it redirects me to:...

Do 301 redirects work on urls that contain query strings?

.htaccess,http-status-code-301
I've searched for this but the answers I've found seem to be around rewriting URLs or for redirecting lots of pages in an entire section and look confusing (lots of regex). We need to add some 301 redirects and everything is working fine except for 13 URLs that contain query...

Getting NotFoundHttpException when accessing a image file in uploads directory in Laravel 5.1

php,.htaccess,laravel,wamp,laravel-5
My setup WAMP Windows 8 I have an uploads directory in iapp <- Root Directory uploads app public Virtual Hosts file (httpd-vhosts.conf) NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot C:/wamp/www/ ServerName localhost </VirtualHost> <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "C:/wamp/www/iapp/public" ServerName iapp.dev ErrorLog "logs/iapp.dev-error.log" CustomLog "logs/dev-iapp.dev-access.log" common <Directory "/"> Order Deny,Allow Deny from...

how to pass %{THE_REQUEST} to a php file with htacess

php,regex,.htaccess,mod-rewrite
I am trying to get a download system using PHP working and having one small issue. I have this in my htaccess file: RewriteEngine on RewriteRule ^.*$ process.php?%{THE_REQUEST} I am urls like this: /download/path1/path2/some file name.pdf In my php the $_GET looks like this: Array ( [GET_/download/path1/path2/some_file_name_pdf?q] => somevalue HTTP/1.1...

Rewrite rules cause infinite redirect loop

apache,.htaccess,mod-rewrite,url-rewriting
My folder structure looks like this: /var/www/.htaccess /var/www/site/index.php /var/www/site/images/test.png Where the .htaccess file looks like this: RewriteEngine On RewriteCond /site/%{REQUEST_FILENAME} -f RewriteRule ^(.*)$ /site/%{REQUEST_FILENAME} [L] RewriteRule ^(.*)$ /site/index.php [L,QSA] Essentially, I want to rewrite all URLs to the /site/ directory, and have existing files simply rewrite to their paths in...

.htaccess rewrite rule page not found

php,.htaccess,mod-rewrite
If page name doesn't exist then I would like to show page not found instead of a blank white page. .htaccess: RewriteEngine On RewriteRule ^([0-9a-z\-\_]+)?$ page.php?name=$1 [L,QSA,NC] page.php: $name = filter_input(INPUT_GET, 'name'); $result = $mysqli->query("SELECT * FROM pages WHERE name='$name'"); while ($row = $result->fetch_assoc()) { echo $row['content']; } If some...

Redirect non-www to www except subdomains by .htaccess

regex,apache,.htaccess,mod-rewrite
There are a few questions like this, but my question is a little different Redirect non-www to www in .htaccess force non www to www in htaccess Redirect Non-WWW to WWW URLs I want to redirect the non-www version of the website to www, but it should not in any...

Mod Rewrite Maintenance page that uses multiple URLs

windows,.htaccess,redirect,isapi-rewrite
I have a site the uses multiple URLs for a single application. Depending on the URL of the site you will get different content. I need to create a rewrite rule that redirects a user to a different page depending on what URL the user hits. For example: If a...

.htaccess | Too many redirects

apache,.htaccess,mod-rewrite,redirect
I want to add a IP filter into my .htaccess file, but after I applied it, a too many redirects error will show. Content of .htaccess: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301] RewriteCond %{HTTPS} on RewriteCond %{REMOTE_ADDR} xxx.xxx.xxx.xxx...

Laravel - Cloud9 Paginator generating unwanted https links [closed]

php,mysql,.htaccess,laravel,pagination
I just moved my Laravel project over to cloud9 and after spending a bit of time figuring out how to properly configure MySQL to work on it (locating the correct hostname) I have run into another rather odd problem I didn't have in the vagrant box: the site's entire pagination...

mod-rewrite to remove a folder

apache,.htaccess,mod-rewrite
I have the following URL http://www.example.com/folder1/folder2/file.php I want to redirect it to http://www.example.com/demo/folder1/file.php I tried this, but it does not work: RewriteCond %{HTTP_HOST} www.example.com RewriteCond %{REQUEST_URI} ^folder RewriteRule /demo/folder(.*) /folder1/folder2/$1 ...

Htaccess rewrite URL with virtual directory and 2 variables

regex,apache,.htaccess,url,rewriting
its my URL... result.php?team=arsenal&player=ospina I want to like this mysite.com/virtualdirectory/arsenal/ospina.html I tried this code.. cant work.. Not Found RewriteRule ^(.*)/(.*)/(.*).html$ result.php?team=$2&player=$3 [L] The requested URL /subfolder/arsenal/ospina.html was not found on this server. Apache/2.2.8 (Win32) PHP/5.2.6 Server at localhost Port 80 Thanks for helps, Best regards!!...

Rewrite non-dynamic pages using htaccess

apache,.htaccess,mod-rewrite
I've been banging my head since many hours on this and I am unable to come up with a solution. What I need to get done. domain.com/page.php => domain.com/page/ domain.com/category1-name1.php => domain.com/category1/name1/ domain.com/category2-name1.php => domain.com/category2/name1/ Details: I have couple of files with the following names & I want them to...

htaccess redirect to subdomain based on query string

php,apache,.htaccess,redirect,joomla
I searched for similar questions but none of them was applicable to my situation. What I need to do is redirect from old url's that have specific query string: option=com_virtuemart to a subdomain : http://parts.domain.com Tried bunch of rules and conds but haven't achieved right redirection. It was always redirecting...

Error 404 when trying to upload Codeigniter Project 3.0 to hosting?

php,.htaccess,codeigniter,web-hosting
Hi community I have my PHP system using the 3.0 framework Codeigniter currently running on localhost so now my project went up to my hosting but do not work for me I get a 404 error. Detail the structure of my project: • Path where uploaded my project hosting .htaccess...

CodeIgniter: removing 'index.php' from URL

php,.htaccess,codeigniter,tankauth
I have answered this question previously and even posted the answer to it by myself. I tried most of the answered questions, but it still didn't work. The first question is regarding placement of the .htaccess file, should I keep it with application folder or inside it? and the next...

Codeigniter URLnot found

php,.htaccess,codeigniter
I am using Codeigniter framework in PHP. My website is on apache server. Path: /var/www/example.com/public_html .htaccess RewriteEngine on RewriteCond $1 !^(index\.php|public|\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?$1 But still I am getting this error on accessing this page: www.example.com/test/wallet: The requested URL /test/wallet was not found on...

htaccess errors after upgrading Apache from 2.2 to 2.4

apache,.htaccess
I use 3 hosting for my websites, all of them have the same rules in htaccess. One of the hosting was upgraded from Apache 2.2 to 2.4 and now I am getting errors spam and I don't know how to fix it without lossing the rule. [Mon Jun 15 19:38:33.189697...

mod_rewrite - force redirecting to rewritten URL

apache,.htaccess,mod-rewrite,redirect
I have following URL [1]: www.domain.com/?search=somequery which i want to redirect to [2] www.domain.com/search/somequery I am using following code in my .htaccess: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^search/(.*)$ /?search=$1 [L] Code above works kind of fine since server understands both URLs:...

redirecting https://domain.com to https://www.domain.com

apache,.htaccess,mod-rewrite
I've recently moved my site to HTTPS and im trying to force all http traffic to https and also to the www. version i.e forcing https://domain.com to https://www.domain.com I have this in my htaccess and all http to https works, apart from the redirect from https://domain.com to https://www.domain.com What am...

Htaccess regex: exclude REQUEST_URI

regex,apache,.htaccess,mod-rewrite,redirect
I really tried everything, the tool htaccess tester says that it's ok, but it's not really working. I want to redirect a subdomain to the main domain only if the REQUEST_URI doesn't start with 3 specific strings. I tried without success with: RewriteCond %{HTTP_HOST} ^sub.example.com$ [NC] RewriteCond %{REQUEST_URI} !(aaa|bbb|ccc) RewriteCond...

Force WWW when URL contains path using .htaccess

.htaccess,session,url,redirect
I'm having a problem with my URL and my sessions. I wish to have ALL website pages be forced to use www. As it looks like now, the website looks like this: www.example.com into www.example.com example.com into www.example.com www.example.com/example/ into www.example.com/example/ example.com/example into example.com/example (this is what's wrong) This is...

How do i set a 410 status for any page with a .html file extension?

html,.htaccess,http-status-code-410
I had a site which became a victim of some spam hacks. This is all resolved, I am now just trying to set a 410 status for these pages which are part of Google's index. They 404 right now but I want them gone as quick as can be. Thankfully...

Filtering QUERY_STRING with back references in RewriteCond

php,regex,apache,.htaccess,backreference
I have a PHP script used to process images before displaying them on the web page. The query string has to be checked to reject all requests coming from external domains. If TLD is example.com http://example.com/process.php?img=somepath/images/imgX.png OK http://example.com/process.php?img=http://example.com/anotherpath/folder/images/imgX.png OK http://example.com/process.php?img=http://anotherdomain.com/images/someimg.jpg Rejected! This rewrite rules work on my test server: <IfModule...

Rewrite url not working in htaccess

php,apache,.htaccess,mod-rewrite,url-rewriting
I have website. I just want to rewrite url using .htaccess Here is the code which I want to rewrite: RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} /search_data.php\?keywords=([^&]+)&f=([^\s&]+) [NC] RewriteRule ^/search_data.php/?$ /search/%1/%2? [R=301,L,NC] this the current url http://localhost/mywbsite/search_data.php?keywords=one+piece&f=149 I want to convert this to this http://localhost/mywbsite/search/one-piece/149 I tried above code but...

Apache Alias For External Directory And All Sub Directories

apache,.htaccess,alias
I want to add a alias for my website. So that website.com/alias will go to a folder outside of the root folder. This folder contains a different website so i want to be able to treat this alias as if it were a subdomain. AliasMatch ^/subdir1/(.*)$ /var/www/otherfolder/subdir1/$1 I was hoping...

Redirect specific Url variables

php,.htaccess,mod-rewrite,redirect
My site used to generate URLs like this: /data.php?s=1432862823&type=basic I have modified the program so the new URLs generated are: /d.php?s=1432862823&t=basic Since some people have bookmarked the old URLs I want to write a Rewrite rule that will get them to the new url. I've not this so far: RewriteEngine...

URL Rewrite with .htaccess From /user/projects/index.php?project_id=1 to /user/projects/1

apache,.htaccess,mod-rewrite
I'm having difficulties getting the correct code for my htaccess file to correctly rewrite my URLs. I'm trying to rewrite: www.page.com/user/projects/index.php?project_id=1 to www.page.com/user/projects/1 Here's what I have in my .htaccess file RewriteEngine On RewriteBase / RewriteRule ^projects/([0-9]+)/?$ index.php?project_id=$1 [NC,L] When I go to page.com/users/projects/1 I get a 404 error, so...

how to get parameter value when I use htaccess url rewrite with '-' in value

php,.htaccess
I used htaccess for url rewrite in my gallery page and I used below code in htaccess. RewriteRule ^gallery/(\w+)/(\w+) gallery_image.php?query=gallery&imgid=$1&slug=$2 [QSA,L] Here slug values should be like firstname-lastname-imagetitle; When I use $_REQUEST['slug'] to get parameter value, it returns only firstname. Ex: if slug = 'jum-hague-art-gallery-brown-box' $_REQUEST['slug'] returns only jum. But...

Page doesn't load after .htaccess redirect with parameters

php,.htaccess,url-rewriting
I recently hosted my website on 000webhost.com and once I hosted it, I logged in to check its working. When I click on a link such as message or profile that contains three parameters such as url, id and ref, the page gets redirected but the profile/message page doesn't load....

Silly mod_rewrite issue

.htaccess,mod-rewrite
I think I never asked before a question like this, and I know I should read the manual, so I did, but I simply can't make this work. I need a rewrite rule to move from this: https://www.proevisa.com/ar/idea.php?permalink=proevisa/is-it-safe-to-provide-my-personal-and-finance-information-online to this: https://www.proevisa.com/ar/proevisa/is-it-safe-to-provide-my-personal-and-finance-information-online I don't yet understand if I should update the...

.htaccess - 301 redirect where the URL structures aren't identical

regex,wordpress,.htaccess,mod-rewrite,redirect
I've been looking around for the answer to this but haven't been able to solve it myself. What I'm trying to do is redirect a group of around 1500+ URLs from one format to another, where the only thing that's consistent between the two is a string of numbers at...

Rewrite folders and Remove the trailing slash at the end

php,apache,.htaccess,mod-rewrite
I'm trying to have only one URL without the trailing slash at the end of the URLs/folders, but at the same time I want to re-write this folder to use dynamic pages, for example: if I have: mydomain.com/folder mydomain.com/folder/ and mydomain.com/folder/second mydomain.com/folder/second/ then I want to open only "mydomain.com/folder" and...

How to rewrite example.com/catelogue.php?page=3&cat1=fruit&cat2=apple with .htaccess

php,apache,.htaccess,mod-rewrite,url-rewriting
Can anyone help me with .htaccess rewrite url, I am new to it and stuck with this below problem i have this urls http://example.com/catelogue.php?page=3 http://example.com/catelogue.php?page=3&cat1=fruit&cat2=apple and i want this to be http://example.com/catelogue http://example.com/catelogue/fruit/apple Below is my .htaccess file, but here the problem is I have achieved this (example.com/catelogue/fruit/apple) but I...

Redirect /{POSTID}/{CATID}/{TITLE} to just /{POSTID}/

apache,.htaccess,redirect,rewrite
I need help with a rewrite / redirect rule to fix some duplicate content issues on my website. I have a URL structure that it causing a ton of duplicate content. The same page can be accessed with: /Static1/Static2/Static3/{POSTID}/{CATID}/{TITLE} /Static1/Static2/Static3/{POSTID}/{CATID}/ /Static1/Static2/Static3/{POSTID}/ So, there are 3 copies of every page. I...

URL Rewriting in php CodeIgniter using .htaccess

php,apache,.htaccess,codeigniter,mod-rewrite
I am working on a project in which url Rewriting was done. Here is the link of the old uri http://www.mysite.pk/jobs/search/faisalabad/all-cats But now in the new url I have changed it to http://www.mysite.pk/jobs/pakistan/faisalabad/all-cats what I want to do is to change the redirect all the url's whcih have http://www.mysite.pk/jobs/search/ search...

Openshift redirect to https using flask-base example

python,.htaccess,flask,openshift
I'm trying to run my flask based app on free gear on Openshift only on https. Following this - I have added the .htaccess file to the root of my repo but it seems to be ignored, as it is not redirecting. The article talks about a wsgi directory but...

Apache htaccess redirect file

php,regex,apache,.htaccess,redirect
I want to redirect any request for file from my old website to the same file but with different url on my new website : www.oldwebsite.com/aaa/bbb/ccc/file.txt -> www.newwebsite.com/bbb/ccc/file.txt I have tried this solution on .htaccess file: RewriteEngine On RewriteRule ^(aaa/bbb/ccc/)(.*)$ http://newwebsite.com/bbb/ccc/$2 [R=301,L] but when I try with this url :...

Apache Regex How To Get This Value

php,regex,apache,.htaccess
I have a URI like this: http://example.com/demo/makemoney?matchtype=chancee&network=agagag&ifmobile=1&placement=nyc&adposition=111&copy=25&pid=123&zid=231&mid=234&cid=342&param1=zaleemm&param2=vatansvr I want to get makemoney and after "?" character values. In my .htaccess file write this rule: RewriteRule ^demo/(.*)?(.*)$ demo.php?utm_campaign=$1&$2 [L,NC] But only utm_campaign I get in $_GET super globals. What's true regex?...

.htaccess for language detection

php,apache,.htaccess,mod-rewrite
I need to work with virtual url for handling the language with folder or subfolder like www.example.com/en/xxx/ OR www.example.com/xxx/en OR www.example.com/xxx/xxx/en And all give the same ?lang=en Its possible ? Thanks you I tested this for subdomaine RewriteRule ^(.+)/$ /index.php?a=$1 [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ /index.php?a=$1...

Excluding certain pages from being redirected to https

wordpress,.htaccess,redirect,https,http-redirect
I'm using the following rules on my WordPress website to: Redirect all http pages to https Redirect the careers page to http <IfModule mod_rewrite.c> RewriteEngine On # Go to https if not on careers RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} !^/careers$ [NC] RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R,L] # Go to http if...

Redirecting to rewritten URL

.htaccess,mod-rewrite
When a user visits mysite.com, I'd like them to be taken to mysite.com/welcome. This address is a rewritten version of mysite.com/index.html so it's basically appending /welcome onto the address. I've tried using Redirect in my .htaccess however it loops continuously. Is there any way that I could achieve this and...

How to process argument with dot in .htaccess?

regex,apache,.htaccess,apache2,rewrite
I have this rule list in .htaccess: RewriteEngine on #RewriteCond %{REQUEST_URI} \/([0-9a-z&=\.\[\]{}%-]+)$ [NC] RewriteRule \.incl$ - [R=404] RewriteRule \.dist$ - [R=404] RewriteRule ^handler/.*$ handler/handler.php? [L] RewriteRule ^appsflyer/(.*)$ appsflyer.php$1 [L] RewriteRule ^testlead/.*$ testlead/testlead.php? [L] RewriteRule ^special/(.*)$ special/terminal.php$2 [L] #RewriteCond %{REQUEST_URI} \/([a-zA-Zа-яА-Я0-9_[\]{}%&=-]+)$ [NC] #RewriteRule ^(.*) /link_handler.php?query=%1 [L] RewriteCond %{REQUEST_URI}...

Allow space and other special characters in htaccess url rewrite

php,regex,apache,.htaccess,mod-rewrite
Hi everyone i have this URL: orderprod_cntr/147/ok2%20-%20val1%20val2%20val3%20val4 When ever i open this URL i get 404 error. The htaccess rule that i am using at present is: RewriteRule orderprod_cntr/([-\w]+)/([-\w]+)/?$ controller/orderprod_cntr.php?id1=$1&id2=$2 [L] The error is occurring due to %20 in the URL, without it works fine. Please tell me the correct...

Redirection loop (URL rewriting)

regex,apache,.htaccess,mod-rewrite,rewriting
I'm trying to rewrite my website URLs. I have: http:// website.com/v2/message.php?ID2=123 I want: http:// website.com/v2/message-123.php I tried something in my htaccess but I've a redirection loop :'( Here is my .htaccess: RewriteCond %{QUERY_STRING} ^ID2=([0-9]+)$ RewriteRule message.php? http://website.com/v2/message-%1.php? [L,R=301] Can someone help me with this?...

Redirect only non-existing sub-directories to another domain using wildcard

apache,.htaccess,mod-rewrite,redirect
In Apache, how do i redirect all non-existing directories for one domain (E.g. http://example.com/*.*) to another (e.g. http://example2.com/*.*)? I don't want the redirect to occur if the directory exists on the first server (http://example.com/). Just for non-existing directories. Example: http://example.com/directoryA <--- Exists on the server, so it should NOT redirect....

Https rewrite needs fix when visitors enter www. at the beginning [closed]

php,.htaccess
I want to direct visitors to the https url, so with the below code if a visitor types domain.com he will go to the https://www.domain.com But if he types www.domain.com he will go to the https://www.www.domain.com How can I avoid this? RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} ...

Is it possible to do a “reverse” mod_rewrite?

.htaccess,mod-rewrite
RewriteRule ^id/([^/]*)$ /product.cgi?id=$1 [L] The above will execute example.com/product.cgi?id=* when url example.com/id/* is requested by the user. I would like the other way around, i want to display to the user example.com/id/* when example.com/product.cgi?id=* is requested. Keeping in mind that example.com/id/* does not exist on the server, it would work...

Friendly URL using .htaccess and PHP “include”

regex,apache,.htaccess,mod-rewrite,url-rewriting
I have very little experience with PHP and using .htaccess, though I would like to create SEO-friendly URLs. I have scoured the internet and Stackoverflow searching for a problem similar to mine. I have tried multiple solutions but have had no luck and I am constantly met with errors. So...

What does “!” do in a rewrite Rule?

.htaccess
I am currently looking at an htaccess file. It contains this content RewriteEngine On RewriteRule !\.(css|jpg|png|xml)$ index.php What does the "!" do and is this a valid redirection for css and other critical files?...

Pretty URLs aren't working after upgrade to Mediawiki 1.24.2

.htaccess,ubuntu,mediawiki
So I am moving a Mediawiki site of mine to a new server. The version 1.20.3 worked fine on the old server running Ubuntu 12.04. However, when I copied everything over to my new server running Ubuntu 14.04 it didn't. So after messing with it for a while I decided...

How to write .htaccess file for AJAX page

php,jquery,ajax,.htaccess
I am working on a website which i am going to develop as a CMS. So i am writing .htaccess file. page link and url working fine, but when i performing ajax request then i am getting 404 error for the url. I am placing my .htaccess file code and...

Unable to connect to your database server using the provided settings in Codeigniter

mysql,.htaccess,codeigniter
Actually I'm trying to configure my codeigniter live file to localhost. I have, created a database called test_bs then imported the tables Then change the base_url like $config['base_url']=http://localhost/gu_ci/'; and $config['index_page']='index.php'; in config.php And then did a change on database.php,Which contains $active_group = 'default'; $active_record = TRUE; $db['default']['hostname'] = 'localhost'; $db['default']['username']...

Access normal php file in cake php

php,.htaccess,cakephp
if i use normal php file so display error of controller missing and my normal php file is in order/api.php in base directory so please help me how can i access this path without error my htaccess code is <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1...

.htacces rewrite by cookie value

apache,.htaccess,mod-rewrite,cookies,url-rewriting
I have a website in 2 languages. I'm inserting the text for each language through php constants and I define the user language through a cookie (lang=es or lang=en). Now the base url in each language is www.webname.com/ but i want to rewrite it depending on the language. If the...

How do I strip out ?_escaped_fragment_= using .htaccess

ajax,.htaccess,mod-rewrite,seo
Google discovered that I'm allowing end users to navigate my content using ajax loading, and is loading my pages as a user client rather than requesting them as new page loads. So instead of trying to index www.mysite.com/page, it's requesting www.mysite.com/?_escaped_fragment_=/page Which is not at all what I want it...

Converting .htacess to nginx

.htaccess,nginx
The following is the .htaccess, RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] I used winginx to the get nginx rewrite which is, rewrite ^/(.+)$ /index.php?url=$1 last; But it not working the desired. The original URL is: http://xxxx/foo/info/getinfo/123/ The converted URL should be: http://xxx/foo/index.php?url=info/getinfo/123/...

Why same .htaccess commands working differently in localhost and server?

php,apache,.htaccess,url-rewriting
I have the following .htaccess command for redirection of php pages RewriteRule ^(.*)$ index.php/$1 [L] This code is working in localhost.It is not working in web server. But when code is slightly modified it works in server. RewriteRule ^(.*)$ index.php?/$1 [L] Why is this happening?...

Redirecting all ip to maintenance page except some ips

apache,.htaccess,symfony2
When releasing new versions of my Symfony project, I need to redirect all external ip addresses to a maintenance.html page (which lives into symfony web directory) using apache. Here is the virtualhost file configuration I've created for this purpose but: When I go from an external ip I get 403...

htaccess rewrite url parameter

php,apache,.htaccess,mod-rewrite,url-rewriting
I want to redirect http://localhost:8080/mypproject/?supplier=test123 to http://localhost:8080/myproject/?product_cat=test123 But I don't know how......

AH01630: client denied by server configuration Apache

linux,apache,.htaccess,prestashop,prestashop-1.6
I get this error when trying to access localhost via a browser. 403 Forbidden I use Ubuntu 14.04 LTS Here is my configuration file: etc/apache2.conf # This is the main Apache server configuration file. It contains the # configuration directives that give the server its instructions. # See http://httpd.apache.org/docs/2.4/ for...

htaccess query string redirect not working correctly

.htaccess
I have a situation where I want to actually see the url variable even though the rest of my htaccess site uses readable URLS. The issue is that it is simply showing up as a page not found... This works... RewriteRule ^files/(.+)/from_all_files/$ pages/file.php?slug=$1&from=all-files This does not work RewriteRule ^files/(.+)?from=all-files$ pages/file.php?slug=$1&from=all-files...

redirect certain pages to its equivalent in another domain, otherwise redirect to its homepage

apache,.htaccess,rewrite,url-redirection
I want to use htaccess to redirect certain pages to its equivalent in another domain, other pages redirect to homepage. Like that: http://old-domain.com/certain-page redirected to: http://new-domain.com/certain-page http://old-domain.com/another-certain-page redirected to: http://new-domain.com/another-certain-page Only these pages will be redirected, otherwise, pages have to be redirected to the new domain home page. http://old-domain.com/non-certain-page redirected...

Htaccess Code not working after changing Server

php,regex,.htaccess,mod-rewrite,http-status-code-301
I was using this code in htaccess to strip any directory to index.php RewriteRule ^.(index.+?\.php)$ /$1 [L,NC,R=301] For instance http://www.example.com/toys/index.php http://www.example.com/battery/upload/index.php http://www.example.com/xyz/photos/index.php It was changing redirecting all of them to http://www.example.com/index.php Now when i changed my server - this code is causing 404 pages Is there any alternate modification which...

.htaccess mod_rewrite not consistent

php,apache,.htaccess,mod-rewrite
Here is a sample from my .htaccess file: RewriteEngine On RewriteRule ^login/?$ loginregister.php [L] RewriteRule ^register/?$ loginregister.php [L] RewriteRule ^member/([^/]*)$ member.php?id=$1 [L] RewriteRule ^members/?$ members.php [L] RewriteRule ^membership/?$ membership.php [L] RewriteRule ^contact/?$ contact.php [L] RewriteRule ^privacy/?$ privacy.php [L] RewriteRule ^terms/?$ terms.php [L] If I visit example.com/login, it loads example.com/loginregister.php. The...

.htaccess allow image to display directly

php,regex,apache,.htaccess,redirect
I have many files including images, php& js scripts and subfolders. I need to redirect to index.php for any uri using .htaccess. for example: www.example.com/test should be redirect to index.php But images should not be redirected to index.php. Instead it should be printed directly in browser. For example: www.example.com/sample.jpg should...

How to redirect domain with www or without www

php,.htaccess,mod-rewrite,redirect
I am using the following rewrite rule to redirect domain that has or has not www. RewriteCond %{HTTP_HOST} !^www\.[NC] RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] It works fine for any sub domain name like www.domainname.com/abc.php or domainname.com/abc.php. But not adding https in case of www.domainname.com or domainname.com. I tried...

htaccess rewrite rules conflict

php,.htaccess,url,mod-rewrite
www.example.com/category/sub_category/Having problem with the rewririte rules in .htaccess file. my current .htaccess file looks like this. 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] RewriteRule ^([0-9]+)$ gallery.php?id=$1 [NC,L] I'm trying create urls like the following. www.example.com/product_name/1...

Remove index.php From Sub directory websites URL

php,.htaccess,laravel,mod-rewrite
I am currently in the process of moving a large number of subdomain websites to become sub directory websites. e.g. site1.website.com => website.com/site1. All of these sites use the same code in the same directory. The code will read the site name and load the correct database if it exists....

Codeigniter URL routing issues in .htaccess

php,apache,.htaccess,codeigniter-2
Before you mark it as duplicate FIY I have tried all solutions I could find on SO. The url is www.deltadigital.ca config file (if I use $config['base_url'] = 'http://www.deltadigital.ca' - it doesnt work at all) //$config['base_url'] = 'http://www.deltadigital.ca'; $root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST']; $root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); $config['base_url'] = $root;...

Is it possible to allow only the correct pretty url?

php,apache,.htaccess,mod-rewrite,friendly-url
I have these pretty urls: app/category/overview app/category/new app/category/edit/4 app/product/overview app/product/new app/product/edit/4 .htaccess RewriteEngine On RewriteRule ^([a-z]+)/([a-z]+)/?([0-9]*)$ index.phpcontroller=$1&action=$2&id=$3 [NC,L] Is it possible to define that any other other url goes back to the index? p.e. app/i/am/the/fastest/man/alive ---> app/ Help would be much appreciated!...

PHP - .htaccess and GET parameters

php,regex,.htaccess,mod-rewrite,redirect
I am trying to create a simple redirect to another page on login script. Currently I am rewriting my URLS to the following format using .htaccess: RewriteRule ^login$ ?i=l [L] RewriteRule ^login([^/]*)$ ?i=l&=$1 The normal URL is therefore: domain.com/login - although I wish to be able to do the following:...

How can I .htaccess 301 redirect all pages/files (EXCEPT FOR ONE) to new domain?

regex,apache,.htaccess,mod-rewrite
How can I .htaccess 301 redirect all pages/files (EXCEPT FOR ONE) to new domain? I have already made an .htaccess file that successfully redirects most all the different pages and files on my old domain (www.olddomain.com) to my new domain (www.newdomain.com). HOWEVER, I need one page to NOT be redirected...

.htaccess root changed with mod_rewrite

.htaccess,mod-rewrite,root
So i'm trying to rewrite the URL like this: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*) index.php?page=$1 [QSA] Works perfectly but relative paths to JavaScript and CSS get messed up. Shouldn't the line below exclude files ? RewriteCond %{REQUEST_FILENAME} !-f ...

after using mod_rewrite link are not found

php,.htaccess,mod-rewrite
I was changed my url from http://example.com/admin/courses.php?id=1001 to http://example.com/articles/1001 usig this code RewriteEngine On RewriteRule articles/([A-Za-z0-9-]+)/?$ admin/courses.php?id=$1 [NC,L] but after changing the url, all the css, images, js link of course.php page is automatically change from http://example.com/admin/css/style.css to http://example.com/articles/css/style.css I need to help...

Dissallow php execution for CSS folder with htaccess from parentfolder

php,apache,.htaccess
I have a question. I want to give one customer FTP access to the CSS folder of my webshop. I tried to prevent running PHP in this folder, but its not working. I think my problem is, that i dont want to add another .htaccess in the css folder. I...

Best way to block countries [on hold]

php,apache,.htaccess
I was requested to prevent access to a website. There are two ways I know I can choose - 1. At apache level (a tool like this: http://www.ip2location.com/blockvisitorsbycountry.aspx) which generates a long htaccess file with list of IP ranges. The other way I know of is using PHP (be it...

.htaccess URL-Rewrite solution?

apache,.htaccess,mod-rewrite,url-rewriting,rewrite
I need to rewrite my url using .htaccess The url is http://www.domain.com/subfolder/search-brands/index.php/?q=Garment Bags&brand=traveler apos s choice And i want it to work like this http://www.domain.com/subfolder/search-brands/Garment Bags/traveler apos s choice Anyone can make it? Thanks a lot for your help!...

SSL is breaking my htaccess file in WordPress

wordpress,apache,.htaccess,google-compute-engine
My .htacess file is vital not only for redirection but for the look of the site. I'm not sure why the developers of this theme did this but I can't change that. If you navigate to http://akcrossfit.com you'll see the site as it should be. When you navigate to https://akcrossfit.com...

How do I setup Apache to serve multipe local sites at different locations?

php,apache,.htaccess,drupal,drupal-7
I'm trying to setup multiple local Drupal 7 site installations on my local machine. Right now, I have a folder ~/Sites/drupal/7/{{various_drupal_sites}} I'm looking to be able to access any of these sites at site1.drupal.local, site2.drupal.local, etc. The problem is that I'm getting a 403 permission denied both at drupal.local and...

How to redirect URL if it contains “?”?

.htaccess,mod-rewrite
I've come up with RewriteEngine on RewriteRule ^(.*)?(.*)$ http://google.com [P] but this approach works for addresses without ? - it is meant to work only for those with ?. When I try to escape ? with /? - I have redirect no matter if URL has ? or doesn't, when...

Pattern matching in htaccess rewrite condition

apache,.htaccess,mod-rewrite,https
I have a rewrite condition in an .htaccess file which is used to 'not' force specific URLs to use a HTTPS connection but it's matching erroneously on other URLs at present, here's the rewrite rule... RewriteCond %{HTTPS} off RewriteCond !/go/ [NC] RewriteCond %{HTTP_HOST} ^app\.ihasco\.co\.uk [NC] RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] And...

Apache does NOT search parent folders for .htaccess

.htaccess,mod-rewrite,apache2
As you know apache2 is supposed to apply the .htaccess to subfolders if the parent folder has a .htaccess file. My problem is that this does not happen. I have the folders: /var/www/program /var/www/program/rec /var/www/program/rec2 where I want rec and rec2 to inherit the .htaccess of program. This does not...

How can I redirect all visitors to a subdirectory but still have access to the root directory for development

regex,apache,.htaccess,mod-rewrite,redirect
I'm about to start building a site and I've set up an "Under Construction" site at http://positivechange.cl I'd like to work directly on the root directory during development so that I don't have to move all files from a development subdirectory to the root directory, so I'd like to redirect...

Short URL with htaccess on many subfolders with same file

php,.htaccess,mod-rewrite
I have this situation: There are many scripts that can be accessed like this: http://website.com/script1/ http://website.com/script2/ Each script has a display.php file that receives a variable from the index.php file VIA a link. I'm using the $_GET method to reat that variable. Example: http://website.com/script1/display.php?id=124 What I'm trying to do is...

Redirect pages in Sub folder using .htaccess

.htaccess,url-rewriting
I have looked all over for the answer but can't seem to get any examples working so I need some help. I have a website built in PHP (Not using a framework). I have sub-pages in a folder called /some-work/ So the address to these sub pages is www.domain.co.uk/some-work/page I...

change request filename (%{REQUEST_FILENAME}) to new path in .htaccess

regex,apache,.htaccess,mod-rewrite
I'm trying to use RewriteRule in .htaccess same as Alias /var/www/html/core/ Alias /var/www/html/core/latest/. I made this .htaccess in /var/www/html/core: RewriteEngine On #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 ^.*$ - [NC,L] #try new path (/var/www/html/core/latest): RewriteRule ^(.*)$...