Questions tagged [mod-rewrite]

10755 questions
1

votes
4

answer
275

Views

Friendly URL to accept extra params in the “traditional way” (PHP's $_GET)

I am developing a web application using PHP and I am using Apache's mod_rewrite for having 'friendly' urls. I have friendly urls like: mysite.com/article/112 mysite.com/article/145 mysite.com/article/40 Everything is ok but I want to be able to receive extra parameters like this mysite.com/article/1...
Carlos Cardenas
0

votes
1

answer
11

Views

IIS Rewrite based on query string value

I am new to IIS Rewrite, Need someone to assist me, I am in a scenario to redirect to another domain based on querystring value. Ex: Request: http://localhost:50743/api/Values?stdId=1000&stdName='Test' http://localhost:50752/api/Values?stdId=1001&stdName='Test1' http://localhost:50753/api/Values?std...
Vicky S
1

votes
3

answer
57

Views

Is there a way to rewrite my urls without using mod_rewrite and .htaccess?

Is there a way to rewrite my urls from: http://www.website.com/notification.php to http://www.website.com/notification I dont have the permission to turn on mod_rewrite and our organisation doesnt want it either. Is there a way to realise this with php only? Thanks in advance
Khaled Tlili
1

votes
1

answer
101

Views

How mod_jk handling node failure

We have configured mod_jk with two tomcat servers with 2 apache web servers. We wanted to know how mod_jk handling node failure or how it will do a health check.?
Pramod Gouda
1

votes
0

answer
293

Views

The requested URL … was not found on this server

The home page of my wordpress website seems to be wroking correctly but if you click through to any of the other pages I get the following error message: The requested URL /about was not found on this server. There is following htaccess code in the permalink setting: RewriteEngine On RewriteBase / R...
Sanjeev Thakur
1

votes
1

answer
37

Views

Htaccess re-write code conflict

I'm having a conflict with my htaccess file. I´m using the following code to remove the php handles: RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*?)/?$...
Christina Rodriguez
1

votes
1

answer
34

Views

How can I catch all routes with apache and html

I write a js script in index.html that parse URL and redirect to a proper destination. e.g it parses example.com/#/info and shows a proper link. I want that it handle any URL such example.com/xyz. but it shows 404 error. when I add .htaccess like this: RewriteEngine on RewriteBase / RewriteCond %{...
paykoob
1

votes
0

answer
82

Views

.htaccess - redirect folder url to a file, and keep original address in address bar, whether the original url had a trailing slash or not

If a user goes to a URL formatted to look like a directory (http://www.example.com/myfolder/) I need the webserver to display a file and pass the folder name into the querystring, so it actually loads (http://www.example.com/file.php?folder=myfolder) I have got this working if a user types in (http:...
john avison
1

votes
1

answer
20

Views

Remove trailing slash and then execute successive RewriteCond statements

My website have some of the links ending with slash (/). Following are some of the example links of my site. www.website/foo/ www.website/bar Following is the .htaccess file, RewriteEngine on RewriteCond '%{DOCUMENT_ROOT}/static/%{REQUEST_URI}.html' -f RewriteRule '^(.+)' '%{DOCUMENT_ROOT}/static/...
Mallikarjun M
1

votes
1

answer
53

Views

Htaccess Redirect a folder and exclude two subfolders

I can't figure our RewriteRule so I've tried RedirectMatch. I need to match to a folder /2018/ and all other sub-folders but I do not want to redirect /2018/speakers/ or /2018/events/ RedirectMatch 301 ^/2018/$^(speakers|events)($|/) https://example.com/north-america Doesn't seem to work and I reall...
Spencer Padway
1

votes
1

answer
27

Views

Redirect user to the secure connection when hit the domain

I have written a rule in .htaccess it was working great according to the requirement now there is a slight change in the requirement and I am confuse that how can I accomplish that by changing my previous rule the first rule which is working is that when when ever user hit the domain example.com or...
Mohsin Abbas
1

votes
1

answer
43

Views

nginx and htaccess rewrite rule with optional parameters

I'm trying to make a rewrite rule in NGINX and .htaccess. Now, I have a link http://project2.local/recordings which can be accessed like that, but it has an optional parameter camera. So you can access the link also like this: http://project2.local/recordings/camera/1, now it also has another option...
Robin
1

votes
1

answer
84

Views

Rewrite everything exclude index.html

I've got following structure of site: index.html /assets/subpage.html /assets/secondpage.html And I wrote following rules in .htaccess: RewriteRule ^([^\.]+)$ $1.html [NC,L] RewriteEngine On RewriteCond %{REQUEST_URI} !^/assets RewriteRule (.*) /assets/$1 [QSA,L] I want to delete .html from files (...
David
1

votes
1

answer
43

Views

Redirecting Domain to Subfolder

Currently I have this on my htaccess RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ RewriteCond %{REQUEST_URI} !^/real-estate [NC] RewriteRule ^(.*)$ /real-estate/$1 [L] I want to redirect the user mydomain.com -> mydomain.com/real-estate www.mydomain.com - > www.mydomain.com/real...
SKS
1

votes
1

answer
75

Views

Wordpress Permalinks Overriding .htaccess https and force slash

I am wanting to use the following .htaccess however it works to a point but for me to access the sub pages I have to reset my permalinks and there for this section gets reset. It seems in Wordpress currently there is only plugins to do one or another - not both of my goals. Goals: To force HTTP:// t...
Jess McKenzie
1

votes
1

answer
125

Views

Redirecting to backend via htaccess Yii2

I am trying to redirect my url to the admin ( backend ) part on domain/admin via htaccess. Still not very familiar with .htaccess and what I did so far is Main .htaccess in the root directory: #adding the charset AddDefaultCharset utf-8 #hide the structure Options -Indexes #if dir is symbol, follow...
Toma Tomov
1

votes
0

answer
200

Views

.htaccess not working on my webserver (404 - not found) how to fix?

My .htaccess file: RewriteEngine on # Rewrite /foo/bar to /foo/bar.php RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L] # NOTE! FOR APACHE ON WINDOWS: Add [NC] to RewriteCond like this: # RewriteCond %{THE_REQUEST} '^[^ ]* .*?\.php[? ].*$' [NC] The .htaccess simply removes the PHP extension, http://myw...
dizzy
1

votes
1

answer
26

Views

How to direct a Domain to a subfolder on the server it points to in apache htaccess

I have a web server with several Domains pointing to it. I want one domain lets name it www.example.com to go into the folder /example in my Doc Root (e.g. /var/www/example). I do this using this .htaccess code in my Doc Root: RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^(www.)?example.c...
ulanBator
1

votes
0

answer
18

Views

.htaccess Mod Rewrite Issue

I have following rewrite rule in htaccess and its not working for first part for EventList.php. Will appreciate some help to figure out whats wrong. I am adding this in a wordpress website htaccess file. RewriteEngine On RewriteRule ^Local-Event/([0-9]*)$ /Eventbrite.php?page=$1 [QSA] Re...
Sam Seth
1

votes
0

answer
35

Views

Issues with RewriteRule on Generic Anchor Redirect

I want to redirect any request to the root of my site to an anchor on the index. So https://example.com/foo Gets sent to https://example.com/#foo I've written this .htaccess file (it also redirects http requests to https, that part works, but is included for completeness) RewriteEngine On RewriteRul...
Dave Howland
1

votes
0

answer
37

Views

Htaccess redirect to page and change the url

I want to redirect to www.domain.com/store/bg/user/login but to rename the url to www.domain.com/storeadmin/bg/user/login without affect the rendered view. What I am doing to redirect ot the login page on this kind of url www.domain.com/storeadmin is: RewriteCond %{REQUEST_URI} ^/?storeadmin/([a-z]{...
Toma Tomov
1

votes
0

answer
79

Views

Mod_rewrite (.htaccess) causing 500 server error when removing extensions (.html) from URL

I was looking for a solution on many topics (E.g. 1, 2, 3, 4, 5, 6, 7,8). Unfortunately, I did not find a good solution. Overall, I want to achieve the following effect: no www. at the beginning of the URL, no .html or / at end of the URL, URL containing the full path to the file (but without showin...
Maciej Rzepinski
1

votes
0

answer
44

Views

Cloaking parts of URL when force HTTPS in htaccess

This question is about: Forcing HTTPS Keep/make the URL tidy Catch all calls to be directed to a routing file Before I had SSL on my site, I had a RewriteRule like: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /directory/file.php?url=$1...
1

votes
1

answer
27

Views

RewriteRule get error when i call xajax

like a title i have a problem with this rewrite rule I write this RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !\.(font|css|js|images|remote) [NC] RewriteCond %{REQUEST_URI} !^/(font|css|js|images|remote/.*)$ [N...
Weber
1

votes
1

answer
53

Views

Apache ModRewrite full url

I have an single question, can mod-rewrite rewrite full URL param? http://example.com/go/something/after/go - works fine. http://example.com/go/http%3A%2F%2Ftarget.com%2Fpage%3Fid%3D8900 - responses 404 error Current .htaccess rules in /go folder: RewriteEngine On RewriteCond %{REQUEST_FILENAME}...
Eugene X
1

votes
0

answer
15

Views

Rewrite rules for asp site with multiple string values

I am new to rewrite tools and hence posting question here. We are using ASP site with IIS 7 Url rewrite 2.0. We are getting an issue where rules are not working for a specific type of pages. We have two link one is from the oringal web site what ever it generating and other one which we have menti...
John
1

votes
0

answer
79

Views

How to rewrite url in Symfony3

i'm new in symfony. I'm trying to rewrite Url in symfony3. I change .htaccess in web folder but it didn't work. The url is '/view/item/18', it should be '/view/item?view_detail_id=18'. I just try sudo a2enmod rewrite but it didn't work. I found this question for a long time but seem don't have more...
talonfla
1

votes
1

answer
18

Views

What 301 redirect would work for this string format?

I have an ecommerce store with the product URL format: /categoryname/subcat1name/subcat2name/1450--my-widget I will shorten it to: /1450--my-widget I can do the change within the ecommerce software, but I need to set up a mod rewrite redirect for the old URLs. To avoid matching URLs for categories,...
user78955
1

votes
0

answer
325

Views

ProxyPass / ProxyPassReverse vs. simple RewriteRule

I'd like to redirect traffic from http://198.51.100.13/site1/ to the server's port 1001. This works (but don't forget to a2enmod proxy and a2enmod proxy_http first!): RewriteEngine On RewriteRule ^/site1(.*)$ http://localhost:1001$1 [P,L] I have read that it should be possible to do it that way, ins...
Basj
1

votes
1

answer
60

Views

mod_rewrite entire website to front page ONLY of new website

Now I've written dozens of redirects in my time, some with tricky regex, some more tame, but today, the very simplest redirect is stumping me on a CentOS server, running Apache 2.2.3. All I'd like to do is redirect every single request on an old domain, regardless of path and query string, to the fr...
J Griffiths
1

votes
1

answer
19

Views

check if requested file is inside a certain folder and if yes redirect to it

Is it possible to check if a requested file (let's say: www.mysite.com/info.pdf) is inside a certain folder (let's say: www.mysite.com/downloads/, thus the real path would be www.mysite.com/downloads/info.pdf) and if yes, redirect to it in order to get downloaded?
dee
1

votes
2

answer
81

Views

Want to remove specific word from URL with rewrite and redirect to correct URL

In my there is a URL which contains specific word which I want to remove from URL, but original the request should go on that specific word. For example... www.example.com/web/un
Nikunj Ranpura
1

votes
1

answer
25

Views

Two versions of .htaccess 301 redirect

I'm looking to move my site to https and I need to add a rule to the .htaccess file to set up the 301 redirect. I have read a lot of guides for this and there seem to be many different possibilities, but two of them keep coming up over and over again. Why are these two options different? What do th...
shuttermuse
1

votes
0

answer
16

Views

.htaccess - how to load css files when adding a folder virtual through .htaccess file

here are .htaccess codes I took from other sites which are working perfect. Options +FollowSymLinks RewriteEngine on Options -MultiViews RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^\.]+)$ $1.php [NC,L] RewriteRule ^products/add productadd.php [L] last lin...
Emraan Aly
1

votes
1

answer
26

Views

htaccess mod url re-writing

I am rebuilding an old website and have a bunch of old url's that I am having issues re-writing properly. For example, some of my old URLs are structured as the following: mydomain.com/?x=about-us **and** mydomain.com/?x=services I would like the examples to rewrite or redirect to the following: myd...
ADP
1

votes
2

answer
47

Views

Htaccess Rewrite Minimum occurrence of a certain character REGEX

I have: RewriteRule ^([a-z0-9-]{29,}+).php?$ _content.php?_p1=$1 [QSA,L] Instead of the parameter being a minimum of 29, Is there a way we can replace this to have the condition where it matches those with the minimum occurrence of 3 hyphens (-)? '-' minimum 3 per url... ?
Dean Chambers
1

votes
0

answer
34

Views

htaccess perpetually ignored by Apache on MacOS

I am trying to set up a PHP project locally on my Mac but I can't for the life of me get Apache to stop ignoring the .htaccess file. I have edited the apache2/httpd.conf file to enable mod_rewrite.so and set Override All instead of Override None here, as instructed by the internet: # # AllowOverride...
jovan
1

votes
0

answer
250

Views

Receiving 404 url not found on this server for wordpress multisite on localhost

I have been searching for over three weeks for a solution with no luck, simply nothing has worked for me yet. After installing multisite everytime I create a new site i get the 404 url not found on this server. Furthermore when i try to reset permalinks for pages on my main site i get the 404 error...
Mike
1

votes
0

answer
32

Views

Redirect all traffic to https AND www - currently only working on main domain, not subpages

I need to redirect all traffic to both https and www on a WordPress site. I have gone through dozens of stackoverflow posts and feel like I finally found the answer here: htaccess redirect to https://www I am using the code below in my htaccess file and it's somewhat working. The root domain inspire...
jphogan
1

votes
1

answer
23

Views

non mandatory parameter in a friendly-url

I want to write a pretty url for someone.php directory. prolem is it sometimes expects two paramters and sometimes just one. I couldn't handle second parameter. I can write easily for just 1 parameter RewriteRule ^someone/([^.?/]+)$ /someone.php?someone=$1 [L] Howevever i couldn't succeed when i tr...
kai

View additional questions