Mod_rewrite .htaccess Redirect Part Of A Query String

I'm struggling with a redirect problem. I need to redirect the following URL with mod_rewrite thorough .htaccess [URL] to the following [URL] So, basically I just need to remove the

&
before
lang=php

However, the order is important. Sometimes

&lang=php
appears after other variables in the querystring. in this scenario I need the
&

to remain part of

&lang=php

Is this possible? To summarise, if &lang=php appears at the beginning of the query string, remove the &. If &lang=php appears anywhere else in the query string, the & must remain. I would change the script myself but unfortunately I am not the developer, and he doesn't seem too helpful at the moment; this is a quick fix.



ADVERTISEMENT

Redirect Part Of String With Mod_rewrite?

I need a rule in my .htacess file to replace with an underscore and 301 redirect any part of a querystring that contains the space (%20) or the double space (%2520) character. So, for example, if a querystring contains the following parameter

weight=really%2520really%20heavy

The parameter needs to be changed in the URL and redirected to:

weight=really_really_heavy

I need this as a temporary measure; unfortunately I do not have access to the PHP script that produces these parameters but I am waiting for them to be changed.

View 2 Replies View Related

.htaccess - Mod_rewrite To Get Query String?

im now changing this site to another server and rewrite rule does not work. I cannot find the problem. I sent a support ticked to the hosting and they said:

If that statement doesnt work then it will be either incorrect, or not designed to work with the web server we are running. We use Apache version 2.2

The manual for mod_rewrite for apache 2.2 is here...

[URL]

I have looked over and over this manual and I dont see what the difference is for my rule!

I want to get the text after the url/bank/ and send it to url/bank/index.php as a parameter called title! This rule does work on my other server space so I know that the rule does work!

The rule is:

RewriteEngine on
RewriteRule ^bank/([^/.]+)/?$ bank/index.php?title=$1 [L]

View 1 Replies View Related

Apache - .htaccess Redirect Subdirectory As Query String?

I want to create "SEO friendly" links that remove the query string from a web site. There is only one variable, let's call it "page". Here is the following code for my .htaccess file.

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)$ index.php?page=$1

This works in providing the proper redirect. So /applications/ will send to index.php?page=applications.

My index.php will include a view page based on the value of $_GET['page']. Here is some sample code below:

switch ($_REQUEST['page']) {
default:
include ("home.php");
break;

[code]....

Let's make apps.php an exact copy of home.php. home.php loads just fine, but apps.php will not load linked CSS and JScript pages. When apps.php is loaded, it thinks it is in the /apps/ directory. To load the linked pages, I would need to insert a "../" in front of the file name. Then it displays correctly.

How can I properly write the .htaccess file so the home.php and apps.php page can be identical files and produce identical results, instead of the apps.php file being treated as if it were in the /apps/ directory?

View 2 Replies View Related

Redirect Or Mod_rewrite An Expired Image In A Directory Using Htaccess?

I have a redirect setup that looks for an image in a directory and if it does not exist, it will redirect to a php file that resizes an image and saves it to that directory. I got it to work great. Problem now is that I need to find a good way to redirect it if the image that was written is 4 hours old. I looked into Mod_expires but could not find a way to redirect to my php image resizer when the image is 4 hours old.

I know I could do this in PHP but the whole point was to reduce the server load by using apache instead of PHP. The site I'm working on gets several thousand viewers daily so I really need to efficiently cache the resized images. Here's an example of what I'm doing...

Browser requests "http://images.mydomain.com/image/1234_01_thumb.jpg"
Apache Checks if "http://images.mydomain.com/image/1234_01_thumb.jpg" exists
If it does not exist, redirect to to "/image/resize_image.php" and generate a thumbnail in "/images/" folder

Now that I got that working how do I get it to redirect to "/image/resize_image.php" when the "1234_01_thumb.jpg" gets x hours old? At some point someone is going to have to update that photo especially if they uploaded the wrong one so it can't be permanent.

View 2 Replies View Related

Mod_rewrite And .htaccess - Redirect Script To Search Files In Inner Catalogs

I have a catalog /images and this path is used in a script. I need to redirect script to search files in inner catalogs - /images1 /images2 etc. I have such .htaccess but it doesnt work.

RewriteEngine On
RewriteOptions Inherit
RewriteBase /
RewriteCond %{REQUEST_URI} !^images/ [S=5]
# skip next 5 rules (number of lines following, i.e. 2*NDIR+1, where NDIR is number of imgdirs)
[Code]....

View 3 Replies View Related

.htaccess - Mod_rewrite If Query Contains Value?

Recently I solved my issue with mod_rewrite to redirect a domain to a subfolder. Now that I've fixed my original issue, I've hit a another wall.Here is an example structure:

/
/index.php
/content/
/content/styles.css
/domain/
/domain/index.php

For simplicity, /domain/ is the current and top-most folder. In /domain/index.php I am trying to access /content/styles.css. How can I accomplish this? Assume there is no web link to the previous directories. Also ../ does not work as ../ returns the same directory as ./. I thought of a way, but my .htaccess skills aren't very strong and I don't want to spend hours or days piecing together an answer. Let's say I have:

<link rel="stylesheet" type="text/css" href="content/styles.css" />

If I am right, href performs a request for the file. How can I use .htaccess to capture the request and point it to the correct folder? Like if the query string looks like ^/content/(.*)$, and rewrite it back one directory to access ../content instead.=

View 4 Replies View Related

Urgemt: .htaccess Redirect With Query Sting?

I want to redirect 5 pages with querystrings eg:

[code].....

View 3 Replies View Related

Mod_rewrite Matching Both Subdomain And Query String

I'm currently mod_rewriting domain.com/a/123/abc to page.php?this=123&that=abc with:

RewriteRule ^a/([^/]+)/([^/]+)/?$ page.php?this=$1&that=$2 [L]

Additionally I now want to mod_rewrite a.domain.com/123/abc to page.php?this=123&that=abc So both a.domain.com/123/abc and domain.com/a/123/abc will redirect to page.php?this=123&that=abc My problem is matching both the subdomain and the query string. This is what I've been working on but it's still not rewriting properly.

RewriteCond %{HTTP_HOST} ^a.domain.com/ [NC]
RewriteCond %{QUERY_STRING} /([^/]+)/([^/]+)/?$ [NC]
RewriteRule ^(.*) /a/$1/$2 [L]

Note that wildcard domains are set up (*.domain.com). It is just the htaccess mod_rewriting that is failing.

View 1 Replies View Related

.htaccess Redirect Non - WWW To WWW Preserving URI String

I'm running the CodeIgniter platform, which uses .htaccess to accept URLs like [URL] I currently use some .htaccess rewrites, namely (simplified):

RewriteEngine On
RewriteCond %{REQUEST_URI} !^(/index.php|/images|/assets)
RewriteRule ^(.*)$ /index.php/$1 [L]

I want to add a rewrite rule that redirects all non www requests to www. I also want the URI string following the domain name to stay the same in the redirect. For instance, if a user makes a request for [URL], I want the .htaccess file to rewrite the request in the browser as [URL] and then process the request.

View 2 Replies View Related

CURL To Return Query String Of Re-writte URL (mod_rewrite)

I'm trying to tidy up the code of large site I developed a while back. The URLs are re-written using mod_rewrite. I am trying to build an array of associative arrays, each one containing the page title, URL, query string (I used query strings in conjunction with a controller to load pages) and some other things. I really don't have time to build this list by hand.

So I'm trying to write a crawler that will start at index.php, get the page title, URL and query string, add them to an array, build a list of links to URLs on the same website and do the same for them, until all links are exhausted. I am trying to do this remotely from my localhost, although I could run it on my clients host account too.

So far I've gotten stuck because I don't know how to get the query string that is output when mod_rewrite rewrites the URL in the header. It also sucks because once I re-wrote those URLs, I went though the whole site and hard-coded the old internal links to the new SEO friendly URLs.

View 3 Replies View Related

APACHE Mod_rewrite Change Variable Name In Query String

I'm trying to change a variable name in a query string, so it's usable by my PHP code.

The query gets posts from an external system, so I can't control that they are posting a variable name with a space in it. And that makes it impossible for me to use the PHP $_GET function.

I need to change variable%20name to ?new1

And I need to change variable2 to new2

There are many variables passed in the query, but only these two need to be changed. The rest can stay the same or even disappear.

So ?variable%20name=abc&variable2=xyz

Needs to end up as ?new1=abc&new2=xyz

Also, they may not be in this order and there may be more variables

So ?variable%20name=abc&blah=123&blah2=456&variable2=xyz

Could end up as ?new1=abc&new2=xyz

OR as ?new1=abc&blah=123&blah2=456&new2=xyz

View 1 Replies View Related

Extract Part From URL For A Query String?

I need a certain part of a URL extracted.

Example:

http://www.domain.com/blog/entry-title/?standalone=1 is the given URL.
blog/entry-title should be extracted.
However, the extraction should also work with http://www.domain.com/index.php/blog/[…]as the given URL.

This code is for a Content Management System.

What I've already come up with is this:

function getPathUrl() {
$folder = explode('/', $_SERVER['SCRIPT_NAME']);
$script_filename = pathinfo($_SERVER['SCRIPT_NAME']); // supposed to be 'index.php'
$request = explode('/', $_SERVER['REQUEST_URI']);
// first element is always ""
array_shift($folder);
array_shift($request);
// now it's only the request url. filtered out containing folders and 'index.php'.
$final_request = array_diff($request, array_intersect($folder, $request));
// the indexes are mangled up in a strange way. turn 'em back
$final_request = array_values($final_request);
// remove empty elements in array (caused by superfluent slashes, for instance)
array_clean($final_request);
// make a string out of the array
$final_request = implode('/', $final_request);
if ($_SERVER['QUERY_STRING'] || substr($final_request, -1) == '?') {
$final_request = substr($final_request, 0, - strlen($_SERVER['QUERY_STRING']) - 1);
}
return $final_request;
}

However, this code does not take care of the arguments at the end of the URL (like ?standalone=1). It works for anchors (#read-more), though.

View 2 Replies View Related

Get The Value You Pass From One Page As Part Of The Query String?

How do you get the value you pass from one page as part of the query string i.e

htttp://www.somesite.com/postage.pgp?newsid=2

How you you get the value of the variable in the next page, stumped.

View 4 Replies View Related

Multi-string Part Match In Query?

I am currently trying to query a db table which contains vehicle information and match as many parts of a passed string against a particular table field.VEHICLE TABLEVehicleID | Model | Trim LevelString to test for: 4dr 4WD LX ManualFor example, I need to match as many parts of the test string (4dr 4WD LX Manual) against the value in Trim Level then return the ID of the row that matches the best.So my question, is there a way to do this in one query OR do I need to loop it down using likes?

View 2 Replies View Related

Regex - Replacing A Specific Part Of A Query String ?

I use $_SERVER['QUERY_STRING'] to get the query sting.

A example would be a=123&b=456&c=789

How could I remove the b value from the query string to obtain a=123&c=789 where b can be any value of any length and is alpha numeric.

View 5 Replies View Related

Hide Query String In Url With .htaccess?

How to hide all query strings in my url and here i can't use hidden variables for these all because in all times i couldn't send them with form submission..And my page is having four query strings to be sent...

View 9 Replies View Related

Structure Query String In MVC Htaccess Applications?

I was wondering about creating "fake" URL queries in a web application. When you put a .htaccess file in the root folder of a project you can rewrite (behind the scenes) this URL http://www.website.com/blog/view into http://www.website.com/index.php?q=blog/view. That way you can maintain a single access point and create a MVC application out of the path in $_GET["q"].But what about actual query strings? Surely this type of rewrite doesn't offer the flexibility of inputting a variable query string. Thus I liked the idea of the following:http://www.website.com/blog/search?keywords=some+blog+post&limit=10&order=DESBut the minute you put & symbols in your URL, things get smelly. For that reason I'm currently replacing the & symbols with | symbolshttp://www.website.com/blog/search?keywords=some+blog+post|limit=10|order=DESC

View 1 Replies View Related

Get Values From Query String And Pass It To New Page Using .htaccess File?

currently I m using following code in my site in .htaccess file :

RewriteRule ^([^/.]+).php?$ comman.php?cat=$1 [L]

This redirects user to comman.php page say, user requests

http://www.mysite.com/myfolder/page1.php

will redirects to

http://www.mysite.com/myfolder/comman.php?cat=page1

This works fine. My question is how can I achieve following

http://www.mysite.com/myfolder/page1.php?var1=123

to redirect

http://www.mysite.com/myfolder/comman.php?cat=page1&param=123

i.e. whatever value passed to url using get method to add in my new url.

View 3 Replies View Related

Mod_rewrite In Htaccess

Been fooling around with mod_rewrite in htaccess but not getting anywhere. I would like if someone typed 'www.mysite.com/Me' for it to be redirected to 'www.mysite.com/user.php?ID=123' while still showing 'www.mysite.com/Me'. How is that done?

I been reading it would have to be done by translating 'Me' to 'user.php?ID=123'. I don't mind updating the htaccess evertime someone chooses a new name. Meaning when someone chooses 'www.mysite.com/Him' going into htaccess and making a new translation.

View 2 Replies View Related

Htaccess And Mod_rewrite

This is something new to me and i want to try and get it working. i have my own server with Apache 2, PHP 4 and MySql 4 with full access to everything. I put this in the.htaccess file:

RewriteEngine On
RewriteRule ^(.*)$ profile.php?user=$1

and nothing happened. I checked my Apache settings for the .htaccess file, and this is what it is set to:

AccessFileName .htaccess
# and never show them
<Files ~ "^.ht">
Order allow,deny
Deny from all
</Files>

View 13 Replies View Related

.htaccess Mod_rewrite

I'm using .htaccess on a personal site of mine, on a local Apache 1.3 server. I have the following lines in my file: Quote:

RewriteEngine on
RewriteRule !.(gif|jpg|png|css)$ /includes/forward.inc.php

I obviously have a page at includes/forward.inc.php with a simple: Quote:

<?
print "hi?";
?>

When I load a page in Firefox pointing to http://localhost/index.php (and any other page for that matter) it continuously loads, endless-loop style. I commented out the second line and the 'RewriteEngine on' causes no problems on its own, so it's just that second line that causes the browser to load and load and load.

View 6 Replies View Related

Mod_rewrite Via Htaccess

I have an app that requires mod_rewrite, which isn't enabled on the server. However, 1and1 support says I can enable it (I assume by htaccess), but they don't tell me how, but rather provide me with a few links from a Google search. how can i enable mod_rewrite via htaccess? What do I need to put in there? If mod_rewrite was enabled on the server, would there be a "default" config, or default statement or directives, whatever.

View 1 Replies View Related

Use Javascript To Redirect To A URL With A Query String?

Javascript
<script type="text/javascript">
function Edit(id)
[code]...

My problem is the Javascript is OK. The location href example. http://localhost/employee_set.php&edit=30 ...The PHP code is not working. Error is not found.

View 1 Replies View Related

Mod_rewrite .htaccess File?

For some weird reason this works on localhost but doesn't work on remote server---to remove .php extension from ALL php files

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.php [NC,L]

View 3 Replies View Related

Using A .htaccess File With Mod_rewrite?

I am using a .htaccess file with mod_rewrite. The code i am using is:

RewriteRule ^/?([-a-zA-Z0-9]+)/?$ outlets.php?outlet_ext=$1 [L]

This was working fine for me up until now. I just added a wordpress blog (www.mysite.com/blog/) but when i try going to that url the mod_rewrite above seems to be kicking in.

View 6 Replies View Related

Little Mod_rewrite - Add To .htaccess File?

I have a classifieds website. Each classified is linked like this originally:

mydomain.com/ad.php?ad_id=Bmw_M3_M_tech_113620829

What RewriteRule should I use to make this link look like:

mydomain.com/Bmw_M3_M_tech_113620829

Also, what do I need to add to my .htaccess file? This is what I have so far:

[code]...

And I have just enabled mod_rewrite which was disabled at first on my Ubuntu server by using: a2enmod rewrite. Anything else I need to know or do?

View 2 Replies View Related

.htaccess Mod_rewrite Options?

I have a problem with an htaccess url rewrite, that works fine at localhost but doesn't work on my hosting (anhosting).I need to redirect all the request to my index.php page.Here's an example: i would to redirect [URL]....This is my .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

on the hosting i always get redirected to the index.php file, but the $1 parameters results always blank, so my custom framework cannot handle the request correctly.

View 2 Replies View Related

Htaccess Mod_rewrite CPU Usage

If someone had lets say 1-3k files, all of which were accessed VIA mod_rewrite ... Do you think the CPU usage would be unbearably substantial?

View 1 Replies View Related

Parked Domains And Mod_rewrite In Htaccess

I have 3 parked domains on 1 home site. I have a 3 page php/mysql driven site. I want each of the 3 parked domains to be associated with a url variable. So:

parkedone.com should go to homesite.com/page1.php?ID=1
parkedone.com/Page2 should go to homesite.com/page2.php?ID=1
parkedone.com/Page3 should go to homesite.com/page3.php?ID=1

parkedtwo.com should go to homesite.com/page1.php?ID=2
parkedtwo.com/Page2 should go to homesite.com/page2.php?ID=2
parkedtwo.com/Page3 should go to homesite.com/page3.php?ID=2

etc..

I'm not looking to redirect because I want the address bar still to show parkedone.com/Page2 not homesite.com/page2.php?ID=1

View 1 Replies View Related

Mod_Rewrite Versus Htaccess File

Mod_Rewrite versus using .htaccess with Forcetype command. After reading several threads here and elsewhere about Mod_Rewrite it seemed like the answer to making the URLs search engine friendly.

Then articles using a '.htaccess' file with the ForceType command began to appear and quite frankly seems like a simpler and more secure way to go:

<Files FileName>
ForceType application/x-httpd-php
</Files>

After a Google search for "ForceType application/x-httpd-php" numerous articles on the subject make it appear to be the preferred method for rewriting search engine friendly URLs.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved