mod-rewrite

URL rewrite(SLUG) and URL redirection (htaccess)

為{幸葍}努か 提交于 2019-12-23 15:44:01
问题 Below is my php code(qs.php). This file contain url links. Pretty links created by using SLUG. <html> <head></head> <body> <?php function create_slug($string){ $slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string); $slug = strtolower($slug); return $slug; } $slugurl= create_slug('SLUG-text-testing-purpose-only'); $file = 'qs1'; //this is a php file qs1.php $id = '12345678'; //testing ID $complete_url = $file."/".$id."/".$slugurl; ?> <a href ="<?php echo $full;?>"> This is a test link created

htaccess - Rewrite to capture friendly URL or querystring

♀尐吖头ヾ 提交于 2019-12-23 15:36:45
问题 I'm trying to come up with one or more rewrite rules that will take either a friendly url or a url containing the full query string. The plan is to create a text-only page by reading in the URL using PHP's loadHTML. For example: Input 1. http://www.example.com/disclaimer (http://www.example.com/text/disclaimer on text-only version) 2. http://www.example.com/info/aboutus (http://www.example.com/text/info/aboutus on text-only version) 3. http://www.example.com/news?id=123 (http://www.example

Apache RewriteRule pass entire URL as a parameter

僤鯓⒐⒋嵵緔 提交于 2019-12-23 13:15:39
问题 Currently my Apache RewriteRule only passes the path of the original URL as a query parameter to the rewritten URL. How do I send the entire URL (including scheme and authority etc) as a parameter to the rewritten URL? I know %{REQUEST_URI} only passes the path, and I can’t see any Apache environment variables that do pass the entire URL. I’m something of a beginner to Apache configuration so excuse any ignorance on my part, thanks! Here’s my current config: # # Enable Rewrite # RewriteEngine

Zend Framework: get subdomain parameter from route

不想你离开。 提交于 2019-12-23 13:15:12
问题 UPD: Solved. The problem was because we're using nginx as a frontend. So nginx doesn't pass the HTTP_HOST to apache. Hi there! I'm having a problem with getting subdomain parameter in my base controller on a production server while on the localhost it's ok. other parameters from url like controller, action returned as they should. this returns null on production: $agencyName = (string) $this->_getParam('agency'); no changes made to .htaccess: RewriteEngine On RewriteRule ^main - [L,NC]

Why is $_SERVER['PATH_TRANSLATED'] repeating itself?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 12:37:14
问题 I'm trying to create a MVC framework when I noticed the $_SERVER['PATH_TRANSLATED'] variable is doing this: [PATH_INFO] => /test/test2/test3 [PATH_TRANSLATED] => redirect:/index.php/test/test2/test3/test2/test3 This is when I'm accessing the PHP file by http://domain.tld/test/test2/test3 Notice how it is repeating after /test/ This is my .htaccess for rewriting: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d

number base conversion in .htaccess

允我心安 提交于 2019-12-23 12:33:51
问题 I intend to do a url redirection of the form : from: domain.com/A into domain.com/someResourse/id/10 in this redirection the base of the id is changed from 16 to 10 . I wonder if this is possible using .htaccess 回答1: You could use RewriteMap with the external program mapping (prg:). This is a quite adavnced use of mod-rewrite and even of RewriteMap. RewriteLock /var/lock/rewritemaplock.lock RewriteMap base16to10 prg:/somewher/modrewritemapbase16to10.pl RewriteRule - ${base16to10:%{REQUEST_URI

Codeigniter Htaccess and URL Redirect issues

拟墨画扇 提交于 2019-12-23 12:08:54
问题 I am trying to use .htaccess on CodeIgniter, but it is not working. I have already set: AllowOverride All $config['index_page'] = ''; $config['uri_protocol'] = 'REQUEST_URI'; I am using XAMPP on Windows. My .htaccess : RewriteEngine On RewriteCond $1 !^(index\.php|images|scripts|css|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] My URL still contains index.php and, if I try to remove it manually, it returns a 404 error Also my other concern is my login page: whenever I login, my URL is

.htaccess rewrite URL with a question mark “?” only for 1 specific URL

随声附和 提交于 2019-12-23 10:57:56
问题 I already started a topic some weeks ago. But I got now a new problem that is very similar to the old problem: .htaccess rewrite URL with a question mark "?" My aim was this URL: /mysite/component/users/?view=registration Rewrite into this new URL: mysite/registration.html My current .htaccess got this code: RewriteBase /mysite RewriteCond %{QUERY_STRING} ^view=(.*)$ RewriteRule ^component/users/?$ %1.html? [R=301,L] It worked very fine. But then I noticed that this config concerns all URL

.htaccess remove index.php and hide parameter key from URLs

橙三吉。 提交于 2019-12-23 10:28:52
问题 I have the following URL www.example.com/index.php?tag= xxx I want to make it like the following using .htaccess www.example.com/xxx I done it with this code: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+?)/?$ /index.php?tag=$1 [L,QSA] SO if I input this URL: www.example.com/index.php?tag=1000 it be redirect to: www.example.com

Can you write a 301 redirect to an anchor point?

一曲冷凌霜 提交于 2019-12-23 09:47:22
问题 Is this valid and correct? RewriteRule ^myOldPage.html$ /index.php#info [R] I'm specifically interested about the #info part. 回答1: Yes. That's a valid 301 redirect (the HTTP standard allows for any valid URI to be provided as the redirect). Now the caveat: Not all search engines may love the redirect. Google does a fantastic job of handling anchor tags (they even have a patent on this), while others will completely ignore them. As long as that's not an issue, the redirect is technically valid