url-rewriting

remove php extension, stop access of url with .php extension and remove trailing slashes

喜你入骨 提交于 2019-12-02 07:57:47
问题 I want my urls to be extensionless, so no .php extension, I also want there not to be an opportunity to access the URL with a trailing slash. The following removes php extension and thens redirects to the extensionless url if you try to access it with .php I started writing a rule to stop you accessing with a / and redirect, but it does not work, any help? #this removes php extension RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] # stops you accessing url with.php

Apache Redirect in htaccess to subdirectory

≯℡__Kan透↙ 提交于 2019-12-02 07:52:09
问题 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

Htaccess - Rewrite from http to https and www to non-www

最后都变了- 提交于 2019-12-02 07:42:25
问题 I am trying to rewrite form http to https and www to non-www urls. Basically if someone goes to http://www.example.com they need to be redirected to https://example.com and all other instances of wrong urls (http://example.com, etc.). I tried to do this by piecing suggestions together: RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{HTTP_HOST} ^www\.garrysun\.com [NC] RewriteRule ^(.*)$ https://garrysun.com/$1 [L,R=301]

URL-rewriting with index in a “public” folder

岁酱吖の 提交于 2019-12-02 07:40:29
问题 I’m a newcomer in the development world. I desperately try to get the good URL. I checked the site for similar problems but I can’t find exactly what I need. Or I do it badly. Here is the situation: I set up a project for a site whose the index.php file is in a folder named Public. To be clearer, here is the URL I have now to reach the homepage of the built site: http:// Domain Name.com/ Folder / Name of the site/public My concern is about the folder Public: I don’t want it appears in the URL

301 redirect not working in IIS 7

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 07:39:55
I need to create this 301 redirect rule: /blog/item.asp?n=12817 redirect to /blog/item/12817 I created a rule in IIS URL Rewrite module with these parameters : Pattern: ^blog/item.asp\?n=([0-9]+) redirect url: blog/item/{R:1} When I test it in IIS it works fine and it created this rule in my web.config: <rule name="Asp classic Legacy 301 redirect" stopProcessing="true"> <match url="^blog/item.asp\?n=([0-9]+)" /> <action type="Redirect" url="blog/item/{R:1}" appendQueryString="true" /> </rule> But still when I navigate to /blog/item.asp?n=12817 in browser it shows me The resource cannot be

how to change url pattern in struts action

跟風遠走 提交于 2019-12-02 07:34:03
domain/Forum_show.action?pg=2&forum=java How do I rewrite that to: domain/forum/java/pg/2 Steven Benitez Use the URL structure you like right from the start. The ability to map to any URL structure is a feature of the Servlet API. Also, you don't need to have an action extension (the .action part) in Struts2. In my opinion, creating bogus extensions never made sense. Here are a few pages where I have talked about using Named Variable Pattern Matching in order to provide prettier URLs. I use this technique in all of my Struts2 apps and it yields much nicer URLs similar to your second example.

Make url pretty with .htaccess

给你一囗甜甜゛ 提交于 2019-12-02 07:33:10
I need to adopt the following scheme: If the url contains any file/script reference, leave that without rewriting example.com/index.php ---> leave without rewriting url If the url doesn't contains any references, something similar to: example.com/some-thing-is-here Re-write this to: example.com?search.php?q=some-thing-is-here I've found the solution for (1), but they all fail with (2). I am a newbie in htaccess, so need suggestions of how to do it, or a common general method to do it. The following should do what you ask. In addition to excluding files, it also excludes directories.

Rewriting url with htaccess when a directory exists

南笙酒味 提交于 2019-12-02 07:26:32
I'm trying to redirect a dynamic page to a dir, example: url.com/index.php?page=download to url.com/download The rule is very simple: RewriteRule ^download$ /index.php?page=download FULL .HTACCESS RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\.url\.com$ RewriteRule ^(.*) http://url.com/$1 [R=301,L] Redirect 301 /index.php?page=download http://url.com/download RewriteCond %{ENV:REDIRECT_STATUS} 200 RewriteRule .* - [L] RewriteRule ^download$ /index.php?page=download The problem is that I already have a directory named "download" and it's returning me a "403 Forbidden Error". I

how to make nice rewrited urls from a router

谁说胖子不能爱 提交于 2019-12-02 07:24:23
问题 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

Htacess Rewrite Rule - Doesn't work without Trailing Slash

浪子不回头ぞ 提交于 2019-12-02 07:10:51
So I have the following Rewrite Rules: RewriteRule ^([a-z0-9_\-]+)(\.php)?$ index.php?page=$1 [NC,L,QSA] RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?shop=$1&page=index [NC,L,QSA] RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z_-]+).php$ index.php?shop=$1&page=$2 [NC,L,QSA] Everything seems to work great, if I go to domain.com/shop/ then it works fine and shows the index. If I go to domain.com/shop/about.php then it works perfect. The only thing that does not work is when I go to domain.com/shop without a trailing slash, it does not display anything I get a bunch of errors. Does anyone know how to fix