1

I am trying to make a clean url without a .html on the end of the usl instead it would have a trailing slash. For example:-

mydomain.com/webpage.html

instead I am looking for:-

mydomain.com/webpage/

Also what I am looking to do is to send that link to another php page and have the title after the / echo'd out so it is like this:-

mydomain.com/webpage/

'webpage'

I have 2 php files one is the index.php file and the other is the action.php file where the end of the url us echo'd out.

Here is the code for my index.php file:-

<html lang="en-US">
<head>  
</head>
<body>
    <center>
        <h2>This is a sample menu</h2>
        <P>
            <li><a href="test">Test</a></li>
            <li><a href="bandai">Bandai</a></li>
            <li><a href="bowen-studios">Bowen Studios</a></li>
            <li><a href="cs-moore">CS Moore</a></li>
            <li><a href="dark-horse">Dark Horse</a></li>
            <li><a href="dc-direct">DC Direct</a></li>
        </center>
    </body>
</html> 

Here is the code for my action.php file:-

<html lang="en-US">
<head>  
</head>
<body>
    <center>
        <h2>This is a sample menu</h2>
        <P>
            <?php
                $url = $_SERVER['REQUEST_URI'];
                $lastSegment = basename(parse_url($url, PHP_URL_PATH));
                $lastSegment = str_replace("-", " ", $lastSegment);
                $lastSegment = ucwords ($lastSegment);
                echo $lastSegment;
            ?>
            <P>
                <li><a href="index.php">Home</a></li>
            </center>
        </body>
    </html>     

Here is the code for my .htaccess file:-

RewriteEngine On
RewriteBase /  
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*) $1 [L]
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ action.php?category=$1

In the htaccess I am trying to force a trailing slash on the end of the url. If I click a link from the index.php menu then it will paser in the action.php file and echo out the word but when I click home it makes another directory and if I click on another link that also creaters another directory on the same url and it keeps building and building. What I want it to do is to return mack to the index.php file or any other static .php file within that directory and not keep creating virtual directories when a link is clicked.

Example of what is happening:-

mydomain.com/test/index.php/bandai/index.php/bowen-studios/

What I am looking to achieve is when you click the Home link you get taken back to the main homepage or any other php static page and not to continuosly build virtual subdirectories each time you click a link.

Thanks for your help in advance :)

0 Answers0