0

First I like to say I feel so privileged being here. I have used the answer given here for many years and it has saved me many many hours. I have searched for the answer to my current question with no luck. I believe the answers didn't work because I am adding it to my current .htaccess file which is required. I have asked in my current software program (phpfox) forum but they said it could not be done. I will leave it to stackoverflow experts to tell me whether it can be done or not. Here is my current .htaccess file

Options -Indexes
<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase  /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(file)/(.*) PF.Base/$1/$2
RewriteRule ^static/ajax.php index.php
RewriteRule ^themes/default/(.*) PF.Base/theme/default/$1
RewriteRule ^(static|theme|module)/(.*) PF.Base/$1/$2
RewriteRule ^(Apps|themes)/(.*) PF.Site/$1/$2

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

</IfModule>

Here are three examples of the URL for this business page.

DomainName/directory/detail/302/name-of-business/overview/

DomainName/directory/detail/302/name-of-business/aboutus/

DomainName/directory/detail/302/name-of-business/contactus/

I think you get the picture but just in case here is a different business.

DomainName/directory/detail/303/name-of-business/overview/

Now for this business page the /directory/details never changes. The 302 is the primary id of the record in the database table for this business. In that same record is the name-of-business. So if I type in the browser URL DomainName/directory/detail/302 it will still bring me to main overview page even without "name-of-business/overview" at the end of the URL. So I am assuming the php code throws that at the end of the url from the database depending on what menu you click on this specific business.

My dream hope is getting it down to

DomainName/name-of-business/overview

DomainName/name-of-business/contact etc...

But I would even be happy to get rid of at least directory/detail (I am guessing the id "302" is needed since it is the main identifier...just guessing).

DomainName/302/name-of-business/overview

I have tried many different answers here but I feel I also may be putting it on the wrong line in my current .htaccess file. Thank you in advance for any help and your time.

JohnJr
  • 1
  • 1

1 Answers1

0

Try with:

Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase  /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(file)/(.*) PF.Base/$1/$2
RewriteRule ^static/ajax.php index.php
RewriteRule ^themes/default/(.*) PF.Base/theme/default/$1
RewriteRule ^(static|theme|module)/(.*) PF.Base/$1/$2
RewriteRule ^(Apps|themes)/(.*) PF.Site/$1/$2

# Rewrite DomainName/303/... to DomainName/directory/detail/303/...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\d+)(/.*|$) index.php?q=directory/detail/$1$2 [L,QSA]

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

</IfModule>

Rewrite DomainName/303/... to DomainName/directory/detail/303/... but only for external links or once fixed in your pages

Croises
  • 18,570
  • 4
  • 30
  • 47
  • First thanks for the help. It didn't seem to do anything though...and I rebooted the server just in case. But at least it didn't crash the website like 99% of my attempts. I even tried to add a forward slash between $1$2 but no luck. Though I am confused on your statement as I was hoping (using your words) for this....Rewrite DomainName/directory/detail/303/... to DomainName/303/...which is the opposite of what you said. I also didn't understand external links unless your talking what the people will type in or the link url on a text link. Now I need to study your code – JohnJr Oct 23 '16 at 23:27
  • I just thought of something that might be harming my efforts. The page with all the links/images of the business is on the page with the following URL. – JohnJr Oct 23 '16 at 23:43
  • DomainName/directory/ so maybe starting on this page is goofing the htaccess up? Like throwing darts in the wind :) – JohnJr Oct 23 '16 at 23:45
  • Also the more I think about it...the business directory is an add-on module/app so maybe this is effecting it as well. – JohnJr Oct 23 '16 at 23:49
  • RewriteRule ^(Apps|themes)/(.*) PF.Site/$1/$2 – JohnJr Oct 23 '16 at 23:49
  • Sorry I keep hitting the enter key and it posts...frustrating. – JohnJr Oct 23 '16 at 23:50
  • Yes, it was a test, because even if the link is rewritten properly, I do not know if your interface (phpFox) supports it or not. You should effectively change all internal links or use absolute links. – Croises Oct 23 '16 at 23:55
  • Ok, it is not an app but instead falls under the module folder which is part of the htaccess already (RewriteRule ^(static|theme|module)/(.*) PF.Base/$1/$2) so this must run first somehow because the directory the files are located in are really PF.Base/module/directory/ – JohnJr Oct 23 '16 at 23:56
  • I think I will not be able help you more. Sorry – Croises Oct 23 '16 at 23:57
  • Thanks anyways...I really appreciated it. I have wasted weeks trying to figure this out... – JohnJr Oct 24 '16 at 00:01