Jump to content


Staff Alumni
  • Posts

  • Joined

  • Last visited

Everything posted by cags

  1. premiso, will you be using a mirror to perform this talking to?
  2. Sure searching by id is probably quicker, but it's a matter of degrees. If you set the slug field to be an index, is that speed different actually going to be noticeable in a real-world environment?!
  3. Do you have access to edit the VirtualHost? It's certainly not going to be possible to do anything using .htaccess, but theoretically it may be possible to redirect from the vhost. Information in the request is encrypted so you won't have access to it until a certificate is loaded, but it must know what port the connection came in on, it may therefore be theoretically possible to redirect at that point.
  4. This can't be done purely via .htaccess, it's not magic, if the value isn't in the URL, then you can't use it in the script. You would need to update your script to fetch information from the database using 'article-title' instead of using the id (12). Basically you change the title to be the identifier of the article. Thus obviously it would need to be unique. Given the URL you describe it would seem you are already using mod_rewrite rules, these would just need a bit of tweaking to not match the id.
  5. Are you saying that on your server you have a directory in your root called city that has an FL folder with a Miami.html file inside of it and that you wish the url to appear as just /FL/Miami.html without the word city? RewriteEngine On RewriteRule ^(FL/Miami\.html)$ /city/$1 [L] I assume you have more than just the one URL you wish to rewrite, but since you didn't specify any parameters, I'm not going to bother hypothesising as I could be completely off. Either way it's just a matter of creating the correct regular expression to match the first half.
  6. OK, so we have a page on our site that works, it's a post with the id of 121 and is accessed via the URL http://mysite.com/viewItem.php?id=121, this is all fine and dandy but it's not as pretty as we would like to be, we want people to access it via http://mysite.com/121/border-collie-for-sale-to-good-home. Step 1: We need to use mod_rewrite in order to take a request for /121/border-collie-for-sale-to-good-home and serve up /viewItem.php?id=121. RewriteEngine On RewriteRule ^([0-9]+)/[a-z-]+/?$ /viewItem.php?id=$1 [L] We should now be able to type /121/border-collie-for-sale-to-good-home into our address bar, and view the page. Step 2: We need to update the links in our script so that they link to this newly beautified url. <a href="/<?php echo $postid;?>/<?php echo $thetitle;?>" Step 3: Celebrate. There are various nuances that can trip you up along the way, but this is essentially all the steps required.
  7. From memory it's under Windows/System32/drivers/etc/hosts.
  8. If a period is a required character, just add it into the first character set. Incidentally I see you are checking that the request doesn't end in a question mark. The query_string question mark is not part of the string tested against, not I believe a URL safe character.
  9. You don't. That's the point. You are attempting to parse data out of an HTML element, something that regular expressions are not really suited to. The solution shown by silkfire loads the html into a DOM object which are built specifically for handling html.
  10. Windows 7 most certainly isn't ignoring your config file. If anything then it's likely you have another web server such as IIS installed and it is this listening on port 80, not apache (or you are looking at the wrong config file). Look for other installations of Apache / IIS. Or search your hdd for index.htm, index.html, index.php , it should be one of them.
  11. First you need to set-up wildcard subdomains on your DNS. Assuming this is done, something like this should work... RewriteCond %{HTTP_HOST} !example.com RewriteRule .* http://example.com/%{REQUEST_URI} [R=302] Once you're happy it's working you can switch the 302 to 301.
  12. Try it without the character set, i.e. remove the square brackets from the regex, so it is just ^(.*)$
  13. This is a relative path, assets requested by the browser will interpret this as relative to the current url. Since your rewrite makes it look like the file is one folder deep it's looking in the wrong place for the assets, you need to either use a full absolute URL or make them relative to root. In your case slapping a forward slash on the front of that should fix it.
  14. Ahh, all good, at least you solved it.
  15. Probably a stupid question, but how are you attempting to start the server? If you are ssh'd in, are you running it as root (or using sudo). I can't remember whether you get an actual error message with invalid permissions or not.
  16. What other RewriteRules do you have? I don't see how that can cause a loop that would extend your URL, it clearly states if the subdomain is this, rewrite to that. There is no crossover.
  17. It sounds like you are triggering a redirect rather than a rewrite, which will cause the .htaccess to be parsed a second time. This time through the requrest is for page.php?slug=test-here, but when that hit's the rules you are replacing the slug value with the value of the page which is giving page.php?slug=page.php, not quite sure how that would be happening though as normally this would cause an infinite loop and crash. Perhaps it's hitting some kind of rewrite limit first. Either way, you should be able to stop that happening by adding another RewriteCond checking if the file requested actually exists. Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_URI} !\.(exe|jpg|jpeg|png)$ RewriteCond %{REQUEST_URI} !-f RewriteCond %{REQUEST_URI} !-d RewriteRule ^([^/]*)$ page.php?slug=$1 [L]
  18. Firstly I'll assume your DNS settings are setup correctly to allow the subdomains to get forwarded to your VirtualHost, if that is the case then you do something along the lines of... RewriteEngine On RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com RewriteRule ^(.*)$ /dir/%1/$1
  19. There should be no time delay with changes as the file is parsed on a per request basis. If your objective is to simply not allow www and use the root domain instead, why not just use... RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.example\.co\.uk$ [NC] RewriteRule ^(.*)$ http://example.co.uk/$1 [L,R=301]
  20. Step 1: make it work in the format /viewItem.php?id=$1 (I'm assuming you've done this). Step 2: make a rewrite rule that matches your 'pretty' url and redirects it to the other one correctly Based on what you've posted, I'm going to assume that /viewItem.php?id=1 is accessible via viewItem1.htm, so you would do something like... RewriteEngine On RewriteRule ^/?viewItem[0-9]+\.htm$ /viewItem.php?id=$1 If typing /viewItem1.htm in your address bar shows the correct page, Step 2 done. Step 3 : update links on your site to point at the new urls Update all the links on your site so that they read in the pretty format SEF format rather than the old query string. Step 4 : party I'm assuming you know how to do this.
  21. RewriteEngine on RewriteRule ^(login|registracija|kategorije|posmatram|admin)/?$ ./$1.php [L,QSA]
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.