mod-rewrite

mod_rewrite RewriteCond and query string

爷,独闯天下 提交于 2019-12-13 07:29:07
问题 recently, I have been working on a small project for a client. I was thinking about using a wordpress style pretty URL format. I googled around a lot and came accross Apache’s mod_rewrite and RewriteRule , RewriteCond . But didn't find any example which can handle random of parameters. For example: /index.php?param=1 → /index/param/1 /index.php?foo=bar&hour=1&minutes=12 → /index/foo/bar/hour/1/minutes/12 /index.php?page=login&attempt=2 → /index/page/login/attempt/2 or something similar. As

htaccess - creating directories and files of the same name

老子叫甜甜 提交于 2019-12-13 07:28:27
问题 I want to create a bunch of files without an extension showing at the end. The easiest way to do that was to do this: /usa/index.php /usa/alaska/index.php /usa/alabama/index.php /usa/california/index.php What I want to do is this /usa/alaska.php /usa/alabama.php /usa/california.php and have it show up as: /usa/alaska /usa/alabama /usa/california However, I have one more level I want to add to this, the cities /usa/alaska/adak.php /usa/alaska/anchorage.php /usa/california/los-angles.php I don

Apache mod_rewrite rule as subdomain

你离开我真会死。 提交于 2019-12-13 07:25:24
问题 How can be this http://some-url.com/?lang=en rewritten to this: http://en.some-url.com ??? via mod_rewrite? 回答1: You could define all possible languagespecific subdomains as ServerAlias in the VirtualHost-configfile of some-url.com and add following rewriterule RewriteEngine On RewriteCond %{HTTP_HOST} ^some-url\.com$ [NC] RewriteCond %{QUERY_STRING} lang=(.*)$ RewriteRule . http://%1.some-domain.com/? [R=301,L] In your serverside script you can get the actual language by checking SERVER/CGI

Having multiple htaccess in a root directory

别来无恙 提交于 2019-12-13 07:19:54
问题 I have directory in my website where user can upload projects or create sub directories, in the root dir i have a default .htaccess file and default.php which i don't want the user to get access to because i rewrite the dir to load default.php as default index page and also this to file will be copied to any sub dir that the user create. Now my problem is when user try to save .htaccess for the project he want to save it will show that is already exist. is there anything i can do to have

Rewrite domain name/url with htaccess

谁说我不能喝 提交于 2019-12-13 07:16:32
问题 I need to rewrite the following url: mydomain.com/dashboard/index.php?user=john-dow to john-dow.mydomain.com/dashboard/index.php So I want to take the query string value and place it at the beginning of my domain followed by a dot. The goal is to create a customized user url, so it looks very friendly to users. But actually, I don't know how can I do that. Is it possible by .htaccess? If yes, how? 回答1: Use in your dashboard/.htaccess : RewriteEngine on RewriteCond %{HTTP_HOST} !^(.+)\

I can't redirect magento domain to HTTPS and add www

不想你离开。 提交于 2019-12-13 07:14:21
问题 I'm trying to redirect magento from any.example to https://www.example.com htaccess code: <IfModule mod_rewrite.c> ############################################ ## enable rewrites Options +FollowSymLinks RewriteEngine on ############################################ ## you can put here your magento root folder ## path relative to web root #RewriteBase /magento/ ############################################ ## uncomment next line to enable light API calls processing # RewriteRule ^api/([a-z][0-9a

How do I remove index.php from the URL?

感情迁移 提交于 2019-12-13 07:08:39
问题 I'm trying to remove the index.php from the url with .htaccess and I have come half way and I can't figure out what is wrong. I have/using the following settings/system: Codeigniter 2.1.4 Ubuntu 12.04 $config['base_url'] = 'http://localhost/present'; apache2 php5 When I'm trying the following urls: http://localhost/present/test it displays the page. So far so good. http://localhost/present/index.php/test it also displays the page so I get duplicate pages. And that is my problem. I'm using the

How to configure .htaccess file for rewrite rules to get rid of extensions, trailing slashes, www?

冷暖自知 提交于 2019-12-13 07:00:40
问题 This is what I want - When somebody enters site.com/page.php or site.com/page or site.com/page/ , all should work the same, and the url displayed in the address bar should be site.com/page [ I don't like extensions and trailing slashes ] I also want to get rid of the www from the url bar, as it's unnecessary. This is my current .htaccess files Rewrite rules - RewriteEngine on RewriteCond %{HTTP_HOST} ^site\.com RewriteRule ^(.*)$ http://www.site.com/$1 [R=permanent,L] RewriteEngine On

.htaccess mod rewrite automatically using php or something?

六眼飞鱼酱① 提交于 2019-12-13 06:52:52
问题 I've got a number of users, each with the website page like http://www.mysite.com/folder/artist_id.php?id=33 The users need to be able to set their own easy URL such as http://www.mysite.com/userguy that would redirect to the above page. I know how to write these out manually in .htaccess with RewriteRule but, for example, users have a whole control panel created with php and javascript and it's become necessary to allow them to choose the name themselves and have code automatically put in.

Passing GET parameters through htaccess + Codeigniter

安稳与你 提交于 2019-12-13 06:52:26
问题 I am using CodeIgniter Framework with this .htaccess command for "nice urls". RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico) RewriteRule ^(.*)$ /index.php?$1 [L] All URLs, for e.g.: example.com/admin/xxx/ passed as -> example.com/index.php?admin/xxx/ (look like CodeIgniter's ?/class/method/ ) But question is: How can I pass $_GET paramaters? For Example: example.com/admin/xxx/?action=die&time=now I need use GET params od external ajax scripts (f.e.: ElFinder based on CODEIGNTER