FAQ Database Discussion Community


.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!...

Rewrite Problen .htaccess Redirect 301

php,apache,.htaccess,mod-rewrite,redirect
I need put a redirect on a site and a have some problems. I have this original .htccess RewriteEngine on RewriteCond %{REQUEST_URI} \.json$ [NC] RewriteRule .* - [F,L] RewriteRule config/.* - [F,L] RewriteRule config - [F,L] RewriteCond %{REQUEST_FILENAME} -f [NC,OR] RewriteCond %{REQUEST_FILENAME} -d [NC] RewriteRule ^.+$ - [L] RewriteCond %{QUERY_STRING}...

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 ...

adding a question mark to the url in url rewrite in .htaccess

php,apache,.htaccess,mod-rewrite
Hi everybody i am trying to append a question mark at the end of my file name in url rewrite, after which will be my url parameters, like example the expected url is like: http://localhost/project/pass/[email protected] and the rule that i am using is below: RewriteRule ^pass/?(\w.+)-(\w.+)$ view/pass.php?useremail=$1&actcode=$2 [L] but the...

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...

How to enable mod_rewrite on Apache 2.4?

php,wordpress,apache,mod-rewrite,centos7
I'm using Wordpress and wanted to enable pretty urls feature, but they don't work, i'm thinking that it's because of mod_rewrite, but i don't know how to enable it on Apache 2.4 under CentOS 7... I've already try this: grep -i LoadModule /etc/httpd/conf/httpd.conf | grep rewrite but nothing... Also would...

SWF works locally but not loaded from server

mod-rewrite,unity3d,swf,swfobject
Here is the deal. I have SWF build with Unity and embedded into HTML page with swfobject. It works perfectly well when I load page locally (zip), but it always says "Movie not loaded" when I try to load page. from server I have already inspect similar embedded movies (this...

.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...

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...

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...

unable to escape “?” in the url rewriting in htaccess

php,apache,.htaccess,mod-rewrite,url-rewriting
I have URL as: spa-shop/admin/index?docid=abc ,For this URL i am using htacces Rewrite Rule. The rule is as follow: RewriteRule ^((?i)spa-shop)/(admin)/([a-zA-Z\?]*)$ spavendor/index.php?url=spaAdmin/$3 [L] In this the output which i am expecting is : spashop/index.php?url=spaAdmin/index?docid=abc , but I am getting the URl as: spashop/index.php?url=spaAdminShop/index. Please let me know what is the...

htaccess rewrite rule is not working

php,apache,.htaccess,mod-rewrite,redirect
All, I'm trying to redirect the hits via htaccess redirect scripts. Below is my htaccess scripts. Options +FollowSymlinks RewriteEngine on RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^post/(.*)/$ post.php?tag=$1 [L] RewriteRule ^search/(.*)$ search.php?tag=$1 [L] Issue : Index and search page are getting redirected. Post page is...

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]...

css and js files have 403 forbidden error after activating mod_rewrite

php,apache,codeigniter,mod-rewrite
I'm working on an application using Codeigniter Framework . I wanted to remove the index.php from the url , so I activated the mod_rewrite , and I modified the .htacces files , the index.php has been removed , and the application run perfectly but the css files and and js...

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...

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:...

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...

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....

redirect and php in htaccess

php,apache,.htaccess,mod-rewrite
I am facing a weird issue when ugrading to a newer php version (now I have 5.5.9) my old .htaccess tells me: Options +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] direct.php would contain e.g.: <?php if ($id == "") {$link = "http://www.example.com";} if ($id == "10")...

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...

htaccess URL Rewrite - Root to Subfolder (with folder of the same name)

regex,apache,.htaccess,mod-rewrite,url-rewriting
I have a file at www.domain.com/blog/blog.html that I want to rewrite as www.domain.com/blog. I have figured out the rewrite for removing the extension .html but am having either circular issues or end up pointing the blog rewrite to the blog folder when trying to do the above. I am new...

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...

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:...

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...

301 Redirect entire site to new site using .htaccess file

.htaccess,mod-rewrite,redirect,http-status-code-301,http-redirect
Ive got a site siteONE.co.uk that i want to 301 permanent redirect all the pages to another site, siteTWO.co.uk For this im currently using the this .htaccess file below, but im have to type out a new line for each page i want to rediect even though they are all...

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...

.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...

Creating SEO friendly URLs using apache mod_rewrite

php,regex,apache,.htaccess,mod-rewrite
I am trying to convert my ugly URL into SEO friendly URLs using apache mod_rewrite. This is how my current URLs look like: index.php?p=search index.php?p=contact index.php?p=my-account&user=1 index.php?p=my-account&user=1 This is what I expect from rewriting: mydomain.com/search mydomain.com/contact mydomain.com/my-account/1 mydomain.com/my-account/1 If I passed one query string through my URL. I can do...

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...

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...

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...

Apache Rewrite to File System Or Proxy

apache,mod-rewrite
I want to create an Apache mod_rewrite rule to do two things: Serve the contents of a file system directory when /file-system-target is requested and Proxy whenever /file-system-target is not requested. E.g.: RewriteRule ^/file-system-target /path/to/file/system/target [L] RewriteRule ^/(.*) http://localhost:8080 [P] However when watching the output of RewriteLog, the latter rule...

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 ^(.*)$...

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...

mod_rewrite into subdirectory file from folder

php,apache,.htaccess,mod-rewrite
This could be probably duplicate due to unable to find that original even after checked the similar questions list of stackoverflow. Actually if user type myipaddress/gt then it should redirect to myipaddress/gt/gt.htm I tried various mod_rewrites but still gets the 'gt' folder contents listed in browser. I gave the last...

A series of rewriterule without Last [L] Flag

regex,apache,.htaccess,mod-rewrite
UPDATE: today I kind of find out what the problem is : now take a look at smaller version RewriteCond %{REQUEST_FILENAME} (.+) RewriteRule first /landingpage1.php [R,ENV=lang:hi] RewriteCond %{REQUEST_FILENAME} (.+) RewriteRule second /landingpage2.php?id=%1&%{ENV:lang} [R,L] my htaccess file location is /www/h/ folder if I type localhost/h/firstsecond, it returns localhost/landingpage1.php , pattern is...

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....

.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....

.htaccess hotlink protection - add image exception

.htaccess,mod-rewrite
So this is my code: RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://my-site.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://my-site.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.my-site.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.my-site.com$ [NC] RewriteRule .*\.(jpg|jpeg|gif|png|)$ http://www.my-site.com/dontsteal.png [R,NC] But I have this .htaccess file inside the images diretory. I dislike moving the dontsteal.png file from images because the file tree gets...

Apache Virtual Host redirect just for servername

apache,mod-rewrite,virtualhost
I have a virtual server, which supports just subdomains of our company. We're using Apache, and I have virtual hosts set up to serve each of these subdomains. People on our network can reach the website of these subdomains by using just the name in DNS, such as just typing...

mod_rewrite with two parameters

.htaccess,mod-rewrite
Im getting a headache over this. If the requested css file has qp defined it should rewrite as line 1. But if it doesn't it should rewrite as line 2. Why isn't this working? RewriteRule /css/(.*).css?qp=(.*)$ /build/css.php?request=$1&qp=$2 [QSA] RewriteRule /css/(.*).css$ /build/css.php?request=$1 [QSA] Can anyone explain why this isn't working?...

Match last occurence of 4 digits htaccess rewrite

regex,.htaccess,mod-rewrite
I'm wondering what sort of regex I could use to match the last occurence of a set of 4 digits in my url. My url is being formatted like this /ARTIST/ALBUM-4 DIGITS-EXTRA STUFF In the url, "4 DIGITS" will be the last possible occurence of 4 digits together. The thing...

redirect one domain to the other while removing a subdirectory from the uri

.htaccess,mod-rewrite,http-status-code-301
I am trying to redirect a third level domain (sub.domain1.com) but only if it matches a subdirectory: http://sub.domain.com/somefolder This will then be redirected to another domain (domain2.com) but needs to remove the /somefolder part so say this: http://sub.domain.com/somefolder/about Will read like this upon redirect: http://domain.com/about This is what I have...

.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...

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...

htaccess rewrite doesn't work when path has same name as file

php,regex,apache,.htaccess,mod-rewrite
I have a strange problem. Here are two examples of a URL rewrite in my htaccess file. The first one doesn't work and returns the variable for "query" as null in the PHP file. RewriteRule ^search/([A-Za-z0-9-\s]+)$ search.php?query=$1 The second one (that I have used as a test) works perfectly fine....

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...

Mod Rewrite - Disable it for specific folders

php,css,apache,.htaccess,mod-rewrite
I have the following file structure |---api |---css |---img |---js |index.php |rewrite.php |book.php What I basically do is, redirect every single request to rewrite.php and then based on first parameter of request URI, include the corresponding page through PHP. My rewrite.php file: $path = rtrim($_SERVER['REQUEST_URI'], "/"); $elements = explode('/', $path);...

.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...

HTACCESS 301 redirect issue with strange url variables

wordpress,apache,.htaccess,mod-rewrite,redirect
google webmaster tool is notifying me a 404 error about the following url: http://www.giobby.com/&force=1 I added the following rule to htaccess file, but it doesn't work: RewriteCond %{QUERY_STRING} ^&force=1 RewriteRule ^/?$ http://www.giobby.com/? [L,NC,R=301] Can someone suggest me the correct rules? ...

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...

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...

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!...

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...

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?...

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...

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...

Create php variable from URL without get

php,.htaccess,mod-rewrite
I'm generating a download link which I sent through email to download a pdf file. There are some parameters (base64 encoded) in the download link to verify the correct profile/user. I want to be the download link as follows: www.example.com/download/ZW5jb2RlbXljb2Rl The parameters are directly added after the subdirectory. I know...

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 ...

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...

.htaccess rewrite condition to remove 'www' from 'https://www'

.htaccess,mod-rewrite
I just need to add 'https' remove 'www' in every case: user input in browser -> url output www.example.com -> https://example.com http://www.example.com -> https://example.com https://www.example.com -> https://example.com // NOT WORKING I'm using following code: RewriteEngine on RewriteCond %{http_host} ^www\.example\.com [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,NC] RewriteCond %{HTTPS} !on RewriteRule ^(.*)$ https://example.com%{REQUEST_URI}...

Htaccess: HTTPS redirection on page + sub pages

apache,.htaccess,mod-rewrite,redirect,https
Im trying to set a htaccess rule that redirects all pages that come under a specific url to https they currently default to http. Im trying to set a overall rule that includes anything after the /enrolments/ page. As multiple locations are included and more being added, so i do...

How to remove subdirectory using rewriterule with non-www redirection

regex,apache,.htaccess,mod-rewrite,redirect
So I've been fiddling with .htaccess and I was able to remove both removing a subdirectory and having a non-www subdirection. Please find code below: Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC] RewriteRule ^(.*) http://domain.com/$1 [R=301,L] RewriteCond %{REQUEST_URI} !(.*)subdir RewriteRule ^(.*)$ subdir/$1 [L] This can redirect: www.domain.com/subdir/file or www.domain.com/file...

Grouping file extensions for re-writing URL's [.htaccess]

.htaccess,mod-rewrite,url-rewriting,rewrite,file-extension
How can I group these two together; is it like ".(html|php)$" - please provide the code. Note, the answer should work for all file extensions: what is your thoughts on removing every file extension; comment on the code used - as it is rare to find. RewriteCond %{THE_REQUEST} ^GET\ (.*)\.html\...

Apache Mod rewrite not work for me When use (-) in url?

php,regex,apache,.htaccess,mod-rewrite
Apache Mod rewrite not work for me When use (-) in url? I tried to access to page www.example.com/products/ipod/white-ipod-8gb/12345678 it's not work, How can i edit .htaccess file ? RewriteEngine on 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] RewriteCond %{HTTP_HOST} ^example\.com RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] ErrorDocument...

.htaccess SEO Friendly URLs not working with two parameters

php,apache,.htaccess,mod-rewrite,url-rewriting
I am trying to create SEO friendly URLs for my site and I have come to problem that I can´t solve. I can´t figure out how to setup the rewrite rule so it will show for example like this www.mysite.com/shows/late-night and www.mysite.com/news/title-of-article. Here is my htaccess file: RewriteEngine on RewriteRule...

Exclude a deep subdirectory from an .htaccess RedirectMatch

apache,.htaccess,mod-rewrite,url-rewriting
The site's .htaccess file has this existing command: RedirectMatch 404 /directory(/|$) An exception is required to make files from one deep subdirectory accessible while still returning a 404 for all other files under directory. The path to the accessible directory is: /directory/sub/sub/sub/sub If I comment out the existing RedirectMatch, the...

Confused about Htaccess

php,apache,.htaccess,mod-rewrite
I'm having a little bit of trouble with my Htaccess file. RewriteEngine On RewriteBase /testwebsite/ RewriteRule ^home/?$ index.php What i'm trying to accomplish is the following: Whenever the client visits localhost/testwebsite/index.php, he must be redirect to the clean url (localhost/testwebsite/home). Whenever the visitor visits localhost/testwebsite/home, he must stay there but...

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...

.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...

RewriteRule not catching

.htaccess,mod-rewrite
Trying to redirect index.php?page=11. (with the period) to index.php?page=11 (no period). This is a page that somehow was indexed in Google, that breaks with the period in the URL. RewriteRule ^index\.php\?page\=11\.$ index.php?page=11 [R=301] This is not catching....

Why is RewriteRule bad flag delimiters?

php,apache,.htaccess,mod-rewrite
What is causing this? I reviewed other examples in the project but this one eludes me. When I remove the second rule everything works fine. Why is that? What is incorrect about the second rule? RewriteRule ^.*startAd$ /post-ad-step-1.php RewriteRule ^.*startAd/(.*) $ /post-ad-step-2.php?adType=$1 Solution remove the white space before the $....

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...

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...

How to remove the word 'index' in the url [.htaccess]?

.htaccess,mod-rewrite,redirect,url-rewriting,file-extension
Currently, I am using the below code to remove the word 'index' in my urls - however, the issue is that it allows for two versions: one without and one with [the word] - hence, I have referenced the one without (in the HTML) - but the user still might...

Mod rewrite prevening to acces a link

php,apache,.htaccess,mod-rewrite
Hello i made a mode_rewrite rule for http://artplant.websoftit.ro/shop.php?id_cat=1&id=7&subcat=solutii like this RewriteEngine On RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.php$ /shop.php?id_cat=$1&id=$2&subcat=$3 [L] and it seems for some reason id doesn't let me to access this link anymore and i don't know why. Can someone tell me what i did wrong my my mode_rewrite rule? This is...

.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...

mod_rewrite rule to drop the string with m=1 from the URL regardless of its location?

regex,apache,.htaccess,mod-rewrite
How to create a mod_rewrite rule that can change this: exampledomain/blog/2013/10/?view=flipcard&m=1&_escaped_fragment_= To this: exampledomain/blog/2013/10/ And this: exampledomain/blog/review-of-items/?view=timeslide&m=1 To this: exampledomain/blog/review-of-items/ Basically to check inside the final string for m=1 and drop that final string only regardless of the number of slashes beforehand? And please note we are not dropping m=1...

rewrite URL from /index.php?page=about to /page/

php,apache,.htaccess,mod-rewrite
I'm sure this has been posted somewhere else but I can't find it. I have spent a few hours researching and trying everything I can thing of from sample code to generators. I have a site that is currently residing in a subfolder called "new". I will be moving the...

.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...

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:...

.htaccess file making new domain redirect to my original domain

apache,.htaccess,mod-rewrite,redirect
To give a little background that may help understand this. I only had one domain on my host's server initially. I just added a new domain and it was redirecting to my first site. I had to create an .htaccess file redirect my first site so that it would have...

Particular URL redirect to http if request come from particular host

apache,http,mod-rewrite,ssl,url-rewriting
Web server is apache, ssl configured, listening on 443, All http requests will be redirected to https using rewrite rule Issues is all url's are serving through https, but we want to connect to the web server through http if the request is coming for particular url from particular host,...

.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...

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...

Rewrite condition ! being ignored

regex,apache,.htaccess,mod-rewrite,redirect
I'm working on rewrite rules. Every call made to the mobile website should be redirected to the non-mobile version (or in my example, to google) EXCEPT for a few pages. This has to work on several environments but they aren't the issue (asfar as I can see). What I have:...

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...

Block some internal urls using .htaccess in cakephp

regex,apache,.htaccess,mod-rewrite
My site is running on cakephp 2.0 version , I want to block some of my site urls. for example www.exmaple.com/users/register www.example.com/users/login I tried to modify the .htaccess file of root , as well inside app folder but nothing work. my code is <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ app/webroot/...

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...

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...

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...

.htaccess rewrite - redirect pages

apache,.htaccess,mod-rewrite,redirect,rewrite
I would like to know how could I redirect all visitor who is accessing the following addresses: https://example.com/anypage to https://example.com/search/anypage It cannot redirect people who is already at https://example.com/search/anypage to avoid loop. This is my current .htaccess: Options -Indexes +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTPS} off RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}...

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...

Convert .htaccess to nginx, seeking working solution

apache,.htaccess,mod-rewrite,nginx
Hello i am aware that there are some .htaccess2nginx converter outside, and well, still need some help, since it's not working at all. To my problem: Setting up an Imageboard(MyImouto) on Nginx, Imageboard uses .htaccess to redirect from /srv/domain/public/ to /srv/domain/app/... Here is the .htaccess: RewriteEngine On # Images redirection....

.htaccess RewriteRule regex match specific words

regex,.htaccess,mod-rewrite
I need an advice from someone which is a better expert in rewrite rules and regex expressions than me. I have the following rewrite rule: RewriteRule ^([^/]*)/$ /product.php?prod=$1 [L] It basically rewrites any page between the slashes to product.php www.website.com/prod1/ www.website.com/prod2/ www.website.com/apple/ www.website.com/orange/ However, I would like to only rewrite...

mod_rewrite to force ssl in apache24

apache,mod-rewrite,ssl
I am running Apache24 on a FreeBSD 10.1 server. I want to control access to some parts of the website using a mysql database. As authentication is performed using AuthType Basic, I want to force SSL to avoid receiving password in clear text. The following configuration seams to work, but...

How to properly write a RewriteCond for https and subdomains

regex,apache,.htaccess,mod-rewrite,url-rewriting
Thus far I've gotten this far with my RewriteConditions but it's from hacking and slashing from internet examples. They seems to behave a little funny at times, like showing the directory in the url, so I assume I'm not doing it right. The desired behaviour: I have multiple subdomains all...

Redirecting and rewritting multiple urls with htaccess

php,apache,.htaccess,mod-rewrite,redirect
I am trying to redirect and rewrite the following urls but in some cases I want to preserve some values but hide from the url. Here is the example of what I want to get: I have this URLs: www.mysite.com/?a=blue www.mysite.com/?a=red etc www.mysite.com/?a=orange&b=omega&c=echo&d=zulu www.mysite.com/?a=orange&b=alfa&c=charlie&d=delta etc And I want to get...

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......