clean-urls

using mod_rewrite to simulate multiple sub-directories

…衆ロ難τιáo~ 提交于 2019-12-02 17:59:47
问题 My .htaccess file currently looks like this: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /?([A-Za-z0-9-]+)/?$ index.php?page=$1 [QSA,L] It works fine for urls like http://site.com/aaaaa but for urls like http://site.com/aaaa/bbb the $_GET['page'] variable will only contain bbb rather than aaaaa/bbb. Is there a way to get all of the sub-directories in the page variable? 回答1: I suggest adding / to the list of accepted characters in your

htaccess clean URL's what's the best way to do it?

风流意气都作罢 提交于 2019-12-02 01:18:56
I'm working on clean Url's for my website and I noticed that what you find on the internet is pretty much about rewriting your clean urls to the url that your server can work with. So something like this: www.domain.com/profile/username --> www.domain.com/profile.php?u=username RewriteEngine On RewriteRule ^profile/(.*)$ /profile.php?u=$1 [L] So now with this I should link within my website to the cleanurl's. But intuitively it feels more solid/better to link to the 'dirty' url. So in that case you should use rewriterules for the above AND a redirect rule to rederict the 'dirty url' to the

How can I make all my urls extensionless, without trailing slash. And redirect the .php and trailing slash to none?

橙三吉。 提交于 2019-12-01 22:29:09
问题 I want to make all my URLs uniformly clean. Which means all my URLs have no extensions, nor trailing slash, and if a person does enter in a .php or trailing slash, it would simply redirect the person to the clean URL. Example: example.com/blog/file.php and example.com/blog/file/ would both redirect to example.com/blog/file 回答1: In .htaccess try this: RewriteEngine on #unless directory, remove trailing slash RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [R=301,L] #resolve .php

How can I make all my urls extensionless, without trailing slash. And redirect the .php and trailing slash to none?

倾然丶 夕夏残阳落幕 提交于 2019-12-01 21:47:36
I want to make all my URLs uniformly clean. Which means all my URLs have no extensions, nor trailing slash, and if a person does enter in a .php or trailing slash, it would simply redirect the person to the clean URL. Example: example.com/blog/file.php and example.com/blog/file/ would both redirect to example.com/blog/file ryanve In .htaccess try this: RewriteEngine on #unless directory, remove trailing slash RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [R=301,L] #resolve .php file for extensionless php urls RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\

clean URL using .htaccess

只愿长相守 提交于 2019-12-01 11:23:21
I'm trying to redirect the links on my domain. What I'm trying to achieve is: When the user clicks on a link to mydomain.com/index.php?dir=myfolder I want him to be redirected to exactly this URL but the browser bar is supposed to show this URL: mydomain.com/myfolder Since I don't have access to how the links are established (it's a php-site) I am trying to do this with just the .htaccess-file. This is what I have: RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} subdomain.mydomain.com RewriteCond %{REQUEST_URI} (.*)/style.css [OR] RewriteCond %{REQUEST_URI} (.*)/script.js [OR]

SEO friendly URL instead of query string .htaccess

陌路散爱 提交于 2019-12-01 10:28:36
问题 How can I modify the .htaccess file and get SEO friendly URLS instead of a query string. I want to achieve this 3 goals: localhost/example/products/ instead of localhost/example/products-list.php localhost/example/products/38/ instead of localhost/example/products.php?id=38 localhost/example/products/38/red/ instead of localhost/example/products.php?id=38&color=red On another post @anubhava helped me a lot and this is what I have right now for the second point: RewriteEngine on RewriteBase

clean URL using .htaccess

▼魔方 西西 提交于 2019-12-01 07:44:17
问题 I'm trying to redirect the links on my domain. What I'm trying to achieve is: When the user clicks on a link to mydomain.com/index.php?dir=myfolder I want him to be redirected to exactly this URL but the browser bar is supposed to show this URL: mydomain.com/myfolder Since I don't have access to how the links are established (it's a php-site) I am trying to do this with just the .htaccess-file. This is what I have: RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} subdomain.mydomain.com

What is the best way to remove punctuation marks, symbols, diacritics, special characters?

99封情书 提交于 2019-12-01 02:45:26
I use these lines of code to remove all punctuation marks, symbols, etc as you can see them in the array, $pattern_page = array("+",",",".","-","'","\"","&","!","?",":",";","#","~","=","/","$","£","^","(",")","_","<",">"); $pg_url = str_replace($pattern_page, ' ', strtolower($pg_url)); but I want to make it simpler as it looks silly to list all the stuff I want to remove in the array as there might be some other special characters I want to remove. I thought of using the regular expression below, $pg_url = preg_replace("/\W+/", " ", $pg_url); but it doesn't remove under-score - _ What is the

Struts2 seo-friendly url?

为君一笑 提交于 2019-12-01 01:52:34
Instead of Users.action?login=foo I want to have /users/foo/ In spring mvc they have "URI templates" for it, but they are only annotation-based. Is it possible to do such url-s in Struts with xml from-the-box? The only one thing I found was external tool: http://www.progbear.com/voice/2010/struts-2-create-friendly-url-with-urlrewritefilter wildcards in struts do not work with "/" and cannot pass parameters to action. Sure I can get this info from request but I believe Struts should support it. Steven Benitez Yes, you can do this out-of-the-box with Struts2. Check out the

how to remove url (/web/index.php) yii 2 and set route with parameter with clean url?

六眼飞鱼酱① 提交于 2019-11-30 08:50:46
问题 first question: i already remove index.php , but i want remove /web also. this is my .htaccess RewriteEngine on # If a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Otherwise forward it to index.php RewriteRule . index.php and this is config/web.php 'urlManager' => [ 'class' => 'yii\web\UrlManager', // Disable index.php 'showScriptName' => false, // Disable r= routes 'enablePrettyUrl' => true, 'rules' => array( '