Prodigal Son Posted July 16, 2008 Share Posted July 16, 2008 Ok, so I've made my urls are nice. Instead of having: www.mysite.com/index.php?pg=category§=sports&title=the-winner I have: www.mysite.com/sports/the-winner This is the mod rewrite I used: RewriteRule ^([a-z0-9-_]+)/([a-z0-9-_]+)/?$ /index.php?pg=category§=$1&title=$2 [L] That works nicely, but if you type in the url as www.mysite.com/index.php?pg=category§=sports&title=the-winner, that will also work. What do people usually do if you type that in? Do they just redirect them to a 404 page or index page? How would I go about doing that. It seems I can't just swap the above code around . My next question is originally my page works by including files from GET. So if you type in www.mysite.com/includes/startpage.php, you will be able to see that page. What would be the best measure to take on that, just redirect the whole folder to a 404 page? Or index page maybe if there is a difference. Thanks. Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2008 Share Posted July 16, 2008 mod-rewrite actually rewrite the urls from... www.mysite.com/sports/the-winner to www.mysite.com/index.php?pg=category§=sports&title=the-winner so denying access to the later will render your site unusable. Just leave them. If you don't want your includes accessed directly one of the easiest approuches is to simply set a constant within your index.php page. eg; define('IS_INDEX',true); then, within each include file simply check for its existence. if (!isset(IS_INDEX)) { die(); } Quote Link to comment Share on other sites More sharing options...
Prodigal Son Posted July 16, 2008 Author Share Posted July 16, 2008 mod-rewrite actually rewrite the urls from... www.mysite.com/sports/the-winner to www.mysite.com/index.php?pg=category§=sports&title=the-winner so denying access to the later will render your site unusable. Just leave them. Oh I see. But if I leave those URLs up, even if I don't use those links anywhere will search engines still find them? If you don't want your includes accessed directly one of the easiest approuches is to simply set a constant within your index.php page. eg; define('IS_INDEX',true); then, within each include file simply check for its existence. if (!isset(IS_INDEX)) { die(); } I get a weird error when I tried that: Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM But no matter how much I change that around I still get the error, weird. Quote Link to comment Share on other sites More sharing options...
Prodigal Son Posted July 19, 2008 Author Share Posted July 19, 2008 Is it just me or you can't use isset with a constant? I tried instead to check if IS_INDEX != true, then die/exit, but it doesn't seem to work, I can still see the include. So I am trying to just redirect the whole directory. I'm using this: Redirect /includes /index.php But it will do something weird. Say my request is mysite.com/includes/header.php, it would bring me to the index page, but it will also add the file name to the end of the path in the address bar. So it would look like this now: mysite.com/includes/index.php/header.php Anyone know how I would fix this? Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.