Jump to content

Capture Last


Zugzwangle

Recommended Posts

Hi,

 

I have a website and I want to use 'RewriteRule' to redirect. The "htaccess" file, will be located in the /profile/ folder.. for example http://www.mySite.net/profile/newLoc

 

I want to find the word after "profile/", so in the example above, I want it to find "newLoc", then it needs to redirect to http://www.mySite.net/profile.php?profile=newLoc

 

When at http://www.mySite.net/profile.php?profile=newLoc for example, I want it to show only http://www.mySite.net/profile/newLoc

 

I have found a match for the whole website address:

http\:/\/\www\.mySite\.net\/profile\/+(\w+)

However I only need to capture the word after "profile/"..

How do I ammend my code to search for that?

 

And when the user's arrive at http://www.mySite.net/profile.php?profile=newLoc, I want it to display only http://www.mySite.net/profile/newLoc

 

Any help would be glady appreciated.

Link to comment
Share on other sites

There is no reason you can't locate the .htaccess file within the profile folder. You just have to bare in mind that you no longer need to match the profile section as this will have been stripped off the URL you are comparing.

Link to comment
Share on other sites

There is no reason you can't locate the .htaccess file within the profile folder. You just have to bare in mind that you no longer need to match the profile section as this will have been stripped off the URL you are comparing.

 

For organization, wouldn't it be best to place it in the root folder though?

Link to comment
Share on other sites

That's a matter of opinion. Since it only applies to the content of that folder, why would placing it in the root folder make any more organisation sense? From a pure ease of use standpoint, keeping your rules all together may make sense, as I say, it's a matter of opinion. For performance reason it should probably be placed within a conf file.

Link to comment
Share on other sites

That's a matter of opinion. Since it only applies to the content of that folder, why would placing it in the root folder make any more organisation sense? From a pure ease of use standpoint, keeping your rules all together may make sense, as I say, it's a matter of opinion. For performance reason it should probably be placed within a conf file.

 

Hi Cags,

 

Can you ellaborate about the conf file? (ie. example would be nice)  8)

 

Cheers

Link to comment
Share on other sites

That's a matter of opinion. Since it only applies to the content of that folder, why would placing it in the root folder make any more organisation sense? From a pure ease of use standpoint, keeping your rules all together may make sense, as I say, it's a matter of opinion. For performance reason it should probably be placed within a conf file.

 

Point taken. :)

 

Can you ellaborate about the conf file? (ie. example would be nice)  8)

 

Conf file as in the Apache httpd.conf file. You can place your rules in here, if you have access to it. It's done the same way as in a .htaccess file except it needs to be in the <Directory></Directory> tags. Here's a quick example:

 

<Directory /path/to/public_html>
  RewriteEngine On
  RewriteRule ^/some/rewrite/rule$ index.php [L]
</Directory>

 

So if you accessed www.yourwebsite.com/some/rewrite/rule it would show the index.php file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.