
cags
Staff Alumni-
Posts
3,217 -
Joined
-
Last visited
Everything posted by cags
-
Define doesn't work. What do you expect to happen?
-
An image displayed on a website is a simple http request for the image which the browser displays on your site, so I'm not sure what you mean by your second post. It's also not entirely clear which direction you want the redirect to occur in, but here's an example of the mod_rewrite rule you may need. RewriteRule ^pics/.*$ /index.php?id=$1
-
You can't access PHP session data from an .htacess file in that manner. You will have to actually serve the file using PHP as mentioned by pastcow. Assuming you redirect all requests via PHP then it wouldn't matter if somebody copy and pasted the path to the file as you would redirect the request to a php file that would check the session data before reading the requested file data in and returning it.
-
The only relevant rule in your .htaccess file seems to be this one... RewriteRule !(\.(js|css|gif|png|jpg|ico|swf))$ index.php So basically it is getting forwarded to the index.php, if you are receiving a 404 error, this is likely because the routing system in whatever CMS/software you are using doesn't recognise this as a valid route (understandable). There are several ways to go about rectifying this. Adding this line in before the aforementioned one is probably the simplest... RewriteRule ^robots\.txt - [L] ...or you could add .txt as a valid extension into that regex above.
-
I guess I'm missing the point here then. If the folder is supposed to be accessed by the subdomin and looks wrong when accessed by the main domain, why is it accessible from outside the subdomain. Do you only have on vhost with the subdomain as an alias, or is the subdomains DocumentRoot inside the main domains? The simplest .htaccess hack to fix it would probably be to put a .htaccess file in the subdomain folder that checks the subdomain then redirects.... RewriteCond %{HTTP_HOST} ! ^subdomain.example RerwiteRule ^( .*)$ http://subdomain.example.com/$1
-
I assume thorpe meant... project/(.*) But you might want to use + rather than *, otherwise you'll end up with project/ going to a page with an empty name.
-
It's very hard to say, your pattern is far to large to be readable even in the slightest, if you insist on doing it all in one pattern (which I'm not sure I see the point of), then at least look into the x modifier so you can attempt to make it partially readable.
-
That is rather an amusing reply, I up voted it a long time ago It does annoy me though when people blanket throw hissy fits just because you use html and regex in the same post, sometimes it is perfectly valid. Having said that you'd probably be better off using something like simplexml to at least fetch the cover-specs divs from the document. Not sure how you'd fetch the actual details using it, but once you have a single node you could run multiple regexs against it to get the individual values. It would also be a lot easier to read if you had multiple ones rather than the behemoth you currently have. $brandPattern = '~<strong>Brand:</strong> <span class="values">([^<]+)</span><br />~'; // etc ... $dimensionsPattern = '~<strong>Dimension ([A-D]):</strong> <span class="values">(\d+(?:\.\d{1,2})?)</span>~';
-
Asking a question which involves both regular expressions and HTML in the same post is pretty much asking for a grilling, it's generally considered a big fat no-no as you can't accurately model HTML syntax with regular expressions. That being said, if the input url is consistent enough there is nothing to stop you actually applying a pattern to it (with varying degree of success). Your pattern is failing because by default the . character does not match newline characters. You can get around that immediate problem by adding the s modifier to the end of your pattern, after the closing delimiter, which in your case is a tilde (~). With regards to your second question, regex doesn't cope well with variable numbers of matches. Your best bet would be to write a single capture group that would encompasses all the dimensions, and then write a second pattern that can be used on the result of the first to extract the individual pieces of information that you are after.
-
If you just want to skip that folder you can add a RewriteCond to ignore it, something like... RewriteEngine on RewrteCond %{REQUEST_URI} ! ^/blog RewriteRule ^([^/\.]+)/?$ $1.php [L] P.S. I can't remember off hand if that forward slash is required before blog or not, it basically says, only follow this RewriteRule if the requested address doesn't begin with blog.
-
I'm going to go ahead and answer what you've asked, despite the fact I don't think it's what you really want. To redirect that first url to the second will depend on a few things, for instance whether subdomain is a complete wildcard or has a fixed number of values. Assuming it's a complete wildcard you can use something along the lines of... RedirectRule ^([^/]+)/([^/]+/[^/]*)$ http://$1.mysite.com/$2 [R=302,L] I suspect that there's a distinct possibility that what you really want to do (based on the fact it's far more common behaviour) is display the contents of that first page when somebody uses the second url, this is a whole different kettle of fish and would be done something roughly along the lines of... RewriteCond %{HTTP_HOST} ^([^.]+).mysite.com RewriteRule (.*) /%1/$1 [L] But note that you would need a wildcard dns record for subdomains for this to work.
-
Rewrite .htaccess to Make URL case-insensitive
cags replied to jgkgopi's topic in Apache HTTP Server
That's because HTTP is case sensitive (as may be your file system). One way of 'fixing' this would be to use mod_speling to attempt to automatically create this 'mistake'. Assuming the module is enabled you can use the following... CheckSpelling On CheckCaseOnly On You can check if the module is enabled using phpinfo, check under the Loaded Modules section (or just stick that in your .htaccess file, if you get a 500 server error, then it isn't). -
In order to help you with this we will need to know, a.) assuming you already have a working site, what the links currently look like. b.) what you would like a link to look like. c.) what data is required to fetch information for the page from the database.
-
Pretty URLs are a case of placing links on your site that look pretty using plain HTML anchor links (generated with PHP if you prefer), using a regular expression to recognize patterns and move the information from the Request URL to the query string. Then php must be able to identify that information to extract relative information from your data store (usually database). Mod_rewrite is required to successfully rewrite a URL from for example domain.com/product/cuddly-toy to domain.com/product.php?product=cuddly-toy. At that point it's a normal php script that queries the database for cuddly-toy. most people start out using domain.com/product.php?id=32, if this is what you have it's important to understand mod_rewrite cannot convert cuddly-toy to 32. You will either have to keep 32 in the URL for example domain.com/product/cuddly-toy-32 or query the database for cuddly-toy instead of 32.
-
Redirecting url of one server to another while masking the new url
cags replied to naik.apoorv's topic in Apache HTTP Server
The RewriteRule you have have looks more or less correct. The HTTP_HOST value is probably 'dl1.abc.com' though, I don't believe it includes the protocol. Thus your RewriteCond is not matching. Assuming only one URL points at the file containing the .htaccess you can just remove the RewriteCond, otherwise you should just need to remove the protocol part. -
Redirecting url of one server to another while masking the new url
cags replied to naik.apoorv's topic in Apache HTTP Server
It's not possible. You can't redirect to a page on another domain and have the original domain still displayed in the address bar. Imagine the security implications this would have. -
Saying you want ?depId=1&typeCatId=1 to redirect to clothing/mens doesn't sound right to me, surely you want people to visit clothing/mens and to view the other page.
-
Yer, it's the web client that isn't running, not the server. Daniel will need to look into it.
-
a.) I've never seen anyone use a comma to delimit the 'pence' section of a currency, perhaps some people do, but this is easily fixed with str_replace. b.) Making sure it's two decimal places is probably best done with number_format. I don't see any real need for regular expressions at all.
-
Your original question states you wish to check whether an input is in the right format, yet steps one and two are conversions, which has nothing to do with pattern matching. Steps one and two cannot be achieved using preg_match, and will need to be done first. Once you have done the conversion your pattern would be as simple as... $pattern = '#[0-9]{1,3}\.[0-9]{2}#';
-
Where are you placing the directives? Assuming it's in a .htaccess file then you probably want to lose the forward slash at the start of the pattern. RewriteEngine On RewriteRule ^buy-wow-account/?$ /index.php [L] RewriteRule ^sell-wow-account/?$ /sell.php [L] RewriteRule ^about-khaccountsnet/?$ /about.php [L]
-
I've seen/answered this same question before. Why statically declare 'NCAA/Pac-10/Oregon-Ducks' and hard code the teamID, capture the Oregon-Ducks part and use it at the top of your scripts to fetch teamID. Alternatively use the 'Oregon-Ducks' value as a unique ID for fetching the other data, instead of teamID. Same would be true of NCAA and Pac-10 only you don't seems to actually use those values in the script.
-
Wildcard subdomain and Masking with htaccess
cags replied to mcdsoftware's topic in Apache HTTP Server
It's because the redirected url also matches the pattern (since .* matches everything). You should be able to do something like this to avoid that... RewriteCond %{HTTP_HOST} !www.domain.com$ [NC] RewriteCond %{HTTP_HOST} ^([a-z0-9-]+).domain.com [NC] RewriteCond %{REQUEST_URI} !^partners/ [NC] RewriteRule (.*) partners/%1/$1 [P,L] Should only rewrite patterns that done begin with the partners/ directory -
Wildcard subdomain and Masking with htaccess
cags replied to mcdsoftware's topic in Apache HTTP Server
What happens if you remove 'http://domain.com/' from the start of the substitution, leaving you with... RewriteEngine On Options +FollowSymLinks RewriteBase / RewriteCond %{HTTP_HOST} !www.domain.com$ [NC] RewriteCond %{HTTP_HOST} ^([a-z0-9-]+).domain.com [NC] RewriteRule (.*) partners/%1/$1 [P,L] -
No. You cannot mask an address change to a different domain, only to files on the same server.