url-rewriting

how to make nice rewrited urls from a router

烂漫一生 提交于 2019-12-02 04:52:39
I'm making a toolkit for php applications. I've a made a routing system based on some conventions, it works well but i would like to learn how to make mod_rewrite rules or any other stuff to finally make the url good to see and good for seo. The route system starts from a config file that set the app and url roots. $app_root = $_SERVER["DOCUMENT_ROOT"].dirname($_SERVER["PHP_SELF"])."/"; $app_url = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/'; define("APP_URL",$app_url); define("APP_ROOT",$app_root); The route always get start from index.php, wich

Apache Redirect in htaccess to subdirectory

走远了吗. 提交于 2019-12-02 04:38:19
I've built an in house app that needs to start in public folder, directory structure is as follows myapp/conf myapp/tmp myapp/doc myapp/public myapp/public/css myapp/public/js myapp/public/index.php If a user installs it in webroot subdirectory, instead of making myapp/public the webroot, then the URLs would be somehost/myapp/public/index.php How do I redirect with /myapp/.htaccess, so that it forwards everything to /public/index.php BUT also changes the URL to include /public. I have figured out how to redirect to public, but since i'm doing URL Rewrites in /public/, i need $_SERVER['REQUEST

.htaccess RewriteRule not working, need to generate a URL friendly

元气小坏坏 提交于 2019-12-02 04:37:05
I have this dynamic link: http://www.nortedigital.mx/article.php?id=36175&t=dobla_las_manos_el_snte__avala_reforma_educativa and I need to convert in URL friendly like this: http://www.nortedigital.mx/36174/se_enriquecio_elba_en_sexenios_del_pan.html and i have this RewriteRule: RewriteRule ^([^/]*)/([^/]*)\.html$ /article.php?id=$1&t=$2 [L] but doesn't work. Please, anybody can help me? You must capture the query string in a RewriteCond and use that in the RewriteRule RewriteEngine On RewriteCond %{QUERY_STRING} ^id=(\d+)&t=(.+)$ RewriteRule ^/?article\.php$ /%1/%2.html? [R,L] This redirects

Query string rewriting using .htaccess

泪湿孤枕 提交于 2019-12-02 04:29:50
i am trying to rewrite a URL for SEO purpose. The old URL is: http://www.domain.net/index.php?p=beer The new URL should be: http://www.domain.net/beer My Code in the .htaccess is: RewriteRule ^([^/\.]+)/?$ index.php?p=$1 Even after hours of research, i have no clue why this is not working :( Here is the complete .htaccess: RewriteEngine on RewriteCond %{HTTP_USER_AGENT} Teoma RewriteRule ^.* - [F] rewritecond %{HTTP_HOST} !^www\.domain\.net$ [NC] rewriterule ^(.*)$ http://www\.domain\.net/$1 [R=301,L] RewriteCond %{QUERY_STRING} ^p=uppic$ RewriteRule ^index\.php$ /? [L,R=301] RewriteRule ^([^/

Redirect to default language except for /amp/ URLs

梦想的初衷 提交于 2019-12-02 04:23:05
I'm struggling to solve a redirection but without any success. I changed the URLs of my site forcing a default language, before it was site.com/help/ and now it's site.com/en/help/ . Thanks to help from Stack Overflow I made the redirection, but then I faced a new problem with the AMP pages: site.com/amp/help/ are now redirected to site.com/en/amp/help/ while they are supposed to be site.com/amp/en/help/ . Again, thanks to help on this site, I changed the structure of URLs to site.com/en/help/amp/ (amp always at the end). To achieve this, I had to delete the .php extension I had in some pages

redirecting without changing URL

拥有回忆 提交于 2019-12-02 04:20:58
i want to redirect domain domain1.com to domain2.com completely but without changing domain1.com URL. i thought i could do that with .htaccess but i found out that it is not possible because they are to different domains and i should use http:// in .htaccess rule so it would be an external rewriting not an internal rewriting,so the URL will change. is there any other solution? is using iframe the only solution? i have to add that i don't want to change DNS setting for these 2 domains. If both domains point at the same server then you can setup your apache config to point both domains at the

Rewriting URL that contains question mark

只愿长相守 提交于 2019-12-02 04:20:20
I am encountering a problem regarding URL rewriting. I am using Apache's mod rewrite to rewrite URLs. For example, I rewrite URL www.website.com/some/path/ to request.php?string=some/path/ . Then I show specific response for this URL. Right now my rewrite rule looks like this: RewriteRule ^([a-z_/\?]+)$ request.php?string=$1 But the problem begins if I have URL www.website.com/some/data/?id=12&name=John and rewrite it, I get something like this: request.php?string=some/data/?id=12&name=John . It seems that in this example another question mark confuses PHP. If I try to retrieve $_GET['string']

How to convert querystring to paths URL using mod_rewrite?

China☆狼群 提交于 2019-12-02 03:56:57
I'm trying to rewrite a URL that has a query string to its SEO friendly name i.e. consider mysite.com/models?p1=v1 I'd like to rewrite it to mysite.com/models/p1/v1 The user should see the above address in address bar. Any suggesstions? The .htaccess should be: RewriteEngine On RewriteRule ^models/(.+)/(.+)$ models.php?$1=$2 [NC,L] 来源: https://stackoverflow.com/questions/13474950/how-to-convert-querystring-to-paths-url-using-mod-rewrite

Remove subfolder name from WordPress site using htaccess

让人想犯罪 __ 提交于 2019-12-02 03:20:20
I've moved WordPress into sub-folder named /site but the URL now shows http://www.example.com/site . I want it to show without the /site/ subdirectory. Here's my current .htaccess code RewriteEngine On RewriteBase /site/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /site/index.php [L] How do I remove the physical subdirectory from the visible URL? I advice you against messing up the contents of the .htaccess file. Revert the changes that you've made to this file and follow the simple procedue. Login to the admin dashboard.

How to hide my website port number on website url

寵の児 提交于 2019-12-02 03:04:50
问题 My website has implemented by using JAVA. So we have taken VPS and installed Tomcat then deployed My website is appearing like this whenever I click www.mysite.com in url ... it is appearing as below. http://mysite.com:8080/foldername/ But I would like to see my website as www.mysite.com Can any one suggest me what to do .. should I do any changes in htaccess file ? 回答1: If you don't provide the port number in the URL your HTTP requests would be sent to port 80. You can set up a firewall rule